Example of Navigation between views in React Native Android?

后端 未结 3 570
星月不相逢
星月不相逢 2020-12-06 04:19

After check the React Native documentation, I still don\'t understand the best way to create views and navigate between different components.

I don\'t want to use an

3条回答
  •  感动是毒
    2020-12-06 04:55

    I suggest you use react-navigation you can take a look to the Navigator Playground example

    • Components built for iOS and Android
    • Choose between TabNavigator, DrawerNavigator and StackNavigator.
    • Implement your CustomNavigator
    • Develop your own navigation views
    • Share logic between mobile apps, web apps with server rendering.
    • Documentation is pretty straighforward
    • It is redux integrated.
    • It is super easy!
    • Will become the official navigator suggested by react-native!

    Install navigation module.

    npm install --save react-navigation
    

    Import it in your app

    import {
      TabNavigator,
    } from 'react-navigation';
    
    const BasicApp = TabNavigator({
      Main: {screen: MainScreen},
      Setup: {screen: SetupScreen},
    });
    

    ...and navigate

    class MainScreen extends React.Component {
      static navigationOptions = {
        label: 'Home',
      };
      render() {
        const { navigate } = this.props.navigation;
        return (
          

提交回复
热议问题