簡體   English   中英

如何將mapStateToProps / redux添加到react-navigation TabNavigator?

[英]How to add mapStateToProps / redux to react-navigation TabNavigator?

我想構建一個非常簡單的示例: https//reactnavigation.org/docs/tab-based-navigation.html

import React from 'react';
import { Text, View } from 'react-native';
import { TabNavigator } from 'react-navigation'; // 1.0.0-beta.27

class HomeScreen extends React.Component {
  render() {
    return (
      <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
        <Text>Home!</Text>
      </View>
    );
  }
}

class SettingsScreen extends React.Component {
  render() {
    return (
      <View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
        <Text>Settings!</Text>
      </View>
    );
  }
}

export default TabNavigator({
  Home: { screen: HomeScreen },
  Settings: { screen: SettingsScreen },
});

我將如何在mapStateToProps(或任何堆棧導航器)中包裝選項卡導航器。 例如,如果我想為特定選項卡使用動態選項卡名稱。

謝謝。

 const MainRoot =(props) => {
      const myTabbar = TabNavigator({
              Home: LoginForm,
              Settings: RegistrationForm,
              third: TabsView
               },{
               initialRouteName: props.myName
               }
             );
       return <CustomTabNavigator/>;
 }
 const mapStateToProps = state => ({
          myName: state.LibraryMain,
 });
export default connect(mapStateToProps)(MainRoot)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM