forked from software-mansion/react-native-screens
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(iOS): flickering custom header items (software-mansion#2247)
## Description This PR intents to fix flickering custom header items when going to a previous screen on `fabric` architecture. The items are unmounted before the transition happens when `POP` action is dispatched on navigation from JS causing the items to vanish for a moment. The adopted solution uses snapshots of the custom items to be used until the transition's done. Fixes software-mansion#2243. ## Changes - added snapshots of the custom header items - modified `Test556` for repro ## Screenshots / GIFs ### Before https://github.com/user-attachments/assets/9da060ed-b65e-4b32-9ab1-debfc2bfd02d ### After https://github.com/user-attachments/assets/0413fab0-05f6-4e55-adab-f283e01bc551 ## Test code and steps to reproduce - Use `Test556` repro ## Checklist - [x] Ensured that CI passes --------- Co-authored-by: Kacper Kafara <[email protected]>
- Loading branch information
Showing
3 changed files
with
101 additions
and
35 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import * as React from 'react'; | ||
import { Button, StyleSheet, Text, View } from 'react-native'; | ||
import { NavigationContainer, ParamListBase } from '@react-navigation/native'; | ||
import { NativeStackNavigationProp, createNativeStackNavigator } from '@react-navigation/native-stack'; | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
type ScreenBaseProps = { | ||
navigation: NativeStackNavigationProp<ParamListBase>; | ||
} | ||
|
||
export default function App() { | ||
return ( | ||
<NavigationContainer> | ||
<Stack.Navigator | ||
screenOptions={{ | ||
animation: 'fade', | ||
}}> | ||
<Stack.Screen name="First" component={First} options={{ | ||
headerTitle: () => ( | ||
<View style={[styles.container, { backgroundColor: 'goldenrod' }]}> | ||
<Text>Hello there!</Text> | ||
</View> | ||
), | ||
headerRight: () => ( | ||
<View style={[styles.container, { backgroundColor: 'lightblue' }]}> | ||
<Text>Right-1</Text> | ||
</View> | ||
), | ||
}} /> | ||
<Stack.Screen name="Second" component={Second} options={{ | ||
headerTitle: () => ( | ||
<View style={[styles.container, { backgroundColor: 'mediumseagreen' }]}> | ||
<Text>General Kenobi</Text> | ||
</View> | ||
), | ||
headerRight: () => ( | ||
<View style={[styles.container, { backgroundColor: 'mediumvioletred' }]}> | ||
<Text>Right-2</Text> | ||
</View> | ||
), | ||
}} /> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
); | ||
} | ||
|
||
function First({ navigation }: ScreenBaseProps) { | ||
return ( | ||
<Button | ||
title="Tap me for second screen" | ||
onPress={() => navigation.navigate('Second')} | ||
/> | ||
); | ||
} | ||
|
||
function Second({ navigation }: ScreenBaseProps) { | ||
return ( | ||
<Button | ||
title="Tap me for first screen" | ||
onPress={() => navigation.popTo('First')} | ||
/> | ||
); | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
padding: 3, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters