zoukankan      html  css  js  c++  java
  • use react-navigation@2.18.2

    react-native@0.59.10

    1.install

    npm install react-navigation@2.18.2

    2.in App.js

    import React from 'react';
    import { View, Text, Button } from 'react-native';
    import { createStackNavigator, StackActions, NavigationActions } from 'react-navigation'; // Version can be specified in package.json
    
    class HomeScreen extends React.Component {
      render() {
        return (
          <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
            <Text>Home Screen</Text>
            <Button
              title="Go to Details"
              onPress={() => {
                this.props.navigation.dispatch(StackActions.reset({
                  index: 0,
                  actions: [
                    NavigationActions.navigate({ routeName: 'Details' })
                  ],
                }))
              }}
            />
          </View>
        );
      }  
    }
    
    class DetailsScreen extends React.Component {
      render() {
        return (
          <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center' }}>
            <Text>Details Screen</Text>
          </View>
        );
      }  
    }
    const RootStack = createStackNavigator({
      Home: {
        screen: HomeScreen,
      },
      Details: {
        screen: DetailsScreen,
      },
    }, {
        initialRouteName: 'Home',
    });
    
    export default class App extends React.Component {
      render() {
        return <RootStack />;
      }
    }
  • 相关阅读:
    java常用类
    java throw和catch同时使用
    HTML5 input 类型: email及url
    Android中集成支付宝
    HTML5 预加载
    SQLite数据库
    Android开发中如何加载API源码帮助开发
    Java中的static
    HTML5 Web Storage 特性
    gdal1.10编译经验
  • 原文地址:https://www.cnblogs.com/dch0/p/13091735.html
Copyright © 2011-2022 走看看