-
-
Notifications
You must be signed in to change notification settings - Fork 530
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add internal isNewBackTitleImplementation const (#1791)
## Description Because of a bug introduced in #1646 `react-native-screens` v3.21 changed how header's backTitle handles whitespace strings in #1726 To allow for backwards compatibility in @react-navigation/native-stack we need have a way to check if this version or newer is used See react-navigation/react-navigation#11423 for more context. ## Changes Added new `isNewBackTitleImplementation` internal constant that can be used in `@react-navigation/native-stack`. ## Screenshots / GIFs #### This change & react-navigation/react-navigation#11423 applied: https://github.com/software-mansion/react-native-screens/assets/39658211/e2409b46-0725-473d-962b-1acc9deaa469 #### Without this change and react-navigation/react-navigation#11423: https://github.com/software-mansion/react-native-screens/assets/39658211/ec65fd5d-f8e9-4d88-b442-6bfc68e9ee9c ## Test code and steps to reproduce Test1791.tsx You need to apply changes introduced in react-navigation/react-navigation#11423 to `@react-navigation/native-stack` to test these canges. ## Checklist - [x] Included code example that can be used to test this change
- Loading branch information
1 parent
7c2801f
commit d481b3e
Showing
5 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
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
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,63 @@ | ||
import {NavigationContainer} from '@react-navigation/native'; | ||
|
||
import {createNativeStackNavigator} from '@react-navigation/native-stack'; | ||
|
||
import React from 'react'; | ||
import {Button, View} from 'react-native'; | ||
|
||
const Stack = createNativeStackNavigator(); | ||
|
||
const Screen1 = ({navigation}) => ( | ||
<View style={{flex: 1}}> | ||
<Button onPress={() => navigation.navigate('Screen2')} title="Next" /> | ||
</View> | ||
); | ||
|
||
const Screen2 = ({navigation}) => ( | ||
<View style={{flex: 1}}> | ||
<Button onPress={() => navigation.navigate('Screen3')} title="Next" /> | ||
</View> | ||
); | ||
|
||
const Screen3 = ({navigation}) => ( | ||
<View style={{flex: 1}}> | ||
<Button onPress={() => navigation.navigate('Screen4')} title="Next" /> | ||
</View> | ||
); | ||
|
||
const Screen4 = () => <View style={{flex: 1}} />; | ||
|
||
const App = () => { | ||
return ( | ||
<NavigationContainer> | ||
<Stack.Navigator> | ||
<Stack.Screen component={Screen1} name="Screen1" /> | ||
<Stack.Screen | ||
component={Screen2} | ||
name="Screen2" | ||
options={{ | ||
headerBackTitleVisible: false, | ||
headerBackTitle: 'Custom title in back button menu', | ||
}} | ||
/> | ||
<Stack.Screen | ||
component={Screen3} | ||
name="Screen3" | ||
options={{ | ||
headerBackTitle: 'Small title', | ||
headerBackTitleStyle: {fontSize: 8}, | ||
}} | ||
/> | ||
<Stack.Screen | ||
component={Screen4} | ||
name="Screen4" | ||
options={{ | ||
headerBackTitle: 'Custom title', | ||
}} | ||
/> | ||
</Stack.Navigator> | ||
</NavigationContainer> | ||
); | ||
}; | ||
|
||
export default App; |
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
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
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