admin管理员组文章数量:1220843
I would like to hide the Back button in the top-left corner, but I don't have any idea how to do it with react-navigation or react-native.
Just tried to use static navigationOptions = { header: null }
but the < Back
button was still alive.
I was using Modal
and it works, but I want to know how to hide < Back
button without using Modal
.
Thank you in advance!
I would like to hide the Back button in the top-left corner, but I don't have any idea how to do it with react-navigation or react-native.
Just tried to use static navigationOptions = { header: null }
but the < Back
button was still alive.
I was using Modal
and it works, but I want to know how to hide < Back
button without using Modal
.
Thank you in advance!
Share Improve this question edited Feb 10, 2019 at 10:51 ProgrammerPer 1,1911 gold badge12 silver badges28 bronze badges asked Feb 10, 2019 at 5:27 Cloie ParkCloie Park 631 silver badge4 bronze badges5 Answers
Reset to default 9Using headerLeft: () => <></>
works great in iOS, but in Android was still displaying the default back button.
I was able to hide it by adding the headerBackVisible: false
on the screenOptions of the Stack Navigator or you could include it on the options for every Stack Screen.
More info at https://reactnavigation.org/docs/native-stack-navigator/#headerbackvisible
I suppose you're using a StackNavigator and that you don't want a header.
You need to use headerMode: none
in the StackNavigatorConfig.
For example:
const ModalStack = createStackNavigator(
{
HomeScreen: { screen: Home },
ModalScreen: { screen: Modal },
},
{
headerMode: 'none',
mode: 'modal',
}
);
More info in the react-navigation docs.
It depends upon the react navigation version you're using, try this
const ModalStack = createStackNavigator(
{
HomeScreen: { screen: Home },
ModalScreen: { screen: Modal },
},
{
headerMode: 'none',
header: null
}
);
if it is StackNavigator default config, go to StackNavigator:
defaultNavigationOptions: { header: null, },
const Stack = createStackNavigator();
<Stack.Navigator screenOptions={{headerShown: false}}>
createStackNavigator is a function that returns an object containing 2 properties: Screen and Navigator. Both of them are React components used for configuring the navigator.
Now below Stack.Navigator, you can place your screens using <Stack.Screen name="Home" component={HomeScreen} />
. In name, you can give any name, and in component give the name of your component.
本文标签: javascripthow to hide back button in ReactnavigationreactnativeStack Overflow
版权声明:本文标题:javascript - how to hide back button in React-navigationreact-native - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1739351442a2159405.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论