- SDK Version: 36.0.0
- Platforms(Android/iOS/web/all): Expo client on iOS and iOS simulator
I’m trying to create a simple button in header bar who push a new screen.
Like this with a back button : Redirecting to https://reactnavigation.org/docs/stack-navigator
I can’t access navigation.navigate in App.js, it’s undefined.
I already have a BottomTabNavigator but my new button is placed on headerRight in Stack.Navigator in App.js.
The new screen must cover the 5 bottom tabs.
I think that my structure is not the right one to do what I want…
I find a lot of things but nothing is suitable for this SDK version.
App.js
return (
<View style={styles.container}>
{Platform.OS === 'ios' && <StatusBar barStyle="default" />}
<NavigationContainer ref={containerRef} initialState={initialNavigationState}>
<MyStack />
</NavigationContainer>
</View>
);
MyStack
function MyStack(props) {
const {navigation} = props;
return (
<Stack.Navigator>
<Stack.Screen
name="Root"
component={BottomTabNavigator}
options={{
headerRight: ({ navigation }) => (
<View>
<TouchableHighlight
onPress={() => navigation.navigate('Profile')}
style={styles.headerIconRight}
underlayColor={Colors.tabBar}
>
<MaterialCommunityIcons name="shield-account" color={Colors.tabIconDefault} size={26} />
</TouchableHighlight>
</View>
),
}}
/>
<Stack.Screen name="Profile" component={ProfileScreen} />
</Stack.Navigator>
);
}
Icon on the top right
Thanks for the help