简体   繁体   English

如何在 react-native 中向此按钮添加导航

[英]How to add navigation to this button in react-native

I am making an app in React-Native and am trying to add navigation to the buttons I am adding.我正在 React-Native 中制作一个应用程序,并尝试向我正在添加的按钮添加导航。 My question is how should I add navigation to them, as when I click on the buttons now they navigate to nothing?我的问题是我应该如何向它们添加导航,因为当我单击按钮时,它们现在导航到什么都没有?

<RedBtn
        onPress={() => {
          this.setState({ searchMode: true });
        }}
        title={'Order delivered'}
      />

What are you using for navigation?你用什么导航?

If you are using nothing, you should use something like react-navigation , and then you will need to create routes and load your components from there.如果你什么都不使用,你应该使用类似react-navigation的东西,然后你需要创建路由并从那里加载你的组件。

Then you can just do然后你可以做

<RedBtn
        onPress={() => {
          navigation.navigate("SomeOtherPage")
        }}
        title={'Order delivered'}
      />

ref: https://reactnavigation.org/docs/getting-started参考: https://reactnavigation.org/docs/getting-started

You can probably do a little bit of navigation without using react-navigation by doing conditional rendering.您可以通过条件渲染在不使用 react-navigation 的情况下进行一些导航。

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

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