tabbar+stackNavigator

1295 ワード

/**
  • Sample React Native App
  • https://github.com/facebook/react-native
  • @flow */

  • import React, { Component } from 'react'; import { AppRegistry, StyleSheet, Text, View, Button, } from 'react-native'; import {TabNavigator,StackNavigator} from "react-navigation";//1ページComponent{render(){return(this.props.navigation.navigate('Chat',{user:'ユーザー'})}title=「buttonをクリック」>
          
          tab  --1
      
    
    );
    

    }//1ページclass AllContactsScreen extends React.Component{render(){return tab--2}//1ページclass ChatScreen extends React.Component{render(){return ChatScreen}//tab const MainScreenNavigator=TabNavigator({Recent:{screen:RecentChatscreen},All:{screen:AllContactsScreen});//1つのnavにはtab const SimpleApp=StackNavigator({Home:{screen:MainScreenNavigator},Chat:{screen:ChatScreen},})が含まれています.export default class Index extends Component { render() { return ( ); } }
    //tabのiconを2つ設定
    MainScreenNavigator.navigationOptions={title:"2つのtabのnavigation",};
    ChatScreen.navigationOptions={title:[ChatScreenページ],};
    const styles = StyleSheet.create({ container: { flex: 1, justifyContent: 'center', alignItems: 'center', backgroundColor: 'red', } });