简体   繁体   English

React Native:从导航堆栈中删除后退按钮?

[英]React Native: Remove a back button from navigation stack?

So I have a navigation stack that constantly adds pages to it.所以我有一个导航堆栈,它不断地向其中添加页面。 The user can go to the previous page, or the next page.用户可以转到上一页或下一页。 Like a sign up page.就像一个注册页面。

So for example, here is a page with 3 screens (previous page, current page, next page)例如,这是一个有 3 个屏幕的页面(上一页、当前页、下一页)

function MyStack() {
  const Stack = createStackNavigator();
  return (
    <Stack.Navigator>
      <Stack.Screen
        name="Current"
        component={ContentFunction}
        options={{headerTransparent: true, headerTitle: ''}}
      />
      <Stack.Screen name="Back" component={BackFunction} />
      <Stack.Screen
        name="Next"
        component={FirstNamePage}
        options={{
          headerTransparent: true,
          headerTitle: '',
          headerBackTitle: 'Gender',
        }}
      />
    </Stack.Navigator>
  );
}

The problem is, the buttons are piling on top of each other.问题是,按钮堆积在一起。 See below.见下文。

在此处输入图片说明

What I need is to delete the old button, but I don't know how to do that.我需要的是删除旧按钮,但我不知道该怎么做。 Of course I could do it with setting:当然,我可以通过设置来做到这一点:

   <Stack.Screen
        name="Next"
        component={FirstNamePage}
        options={{
          headerLeft: null
        }}
      />

But I cannot do this unless I am on that specific function.但是除非我在那个特定的功能上,否则我不能这样做。 How do I go about doing this?我该怎么做?

Try this尝试这个

    <Stack.Navigator
      screenOptions={{
        headerShown: false
      }}
    >

  <Stack.Screen name="route-name" component={ScreenComponent} />
</Stack.Navigator>

Reference :- Hide header in stack navigator React navigation参考:- 在堆栈导航器 React 导航中隐藏标题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM