gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 17:29:53 25 4
gpt4 key购买 nike

我想构建此处显示的非常简单的示例: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)

关于javascript - 如何将 mapStateToProps/redux 添加到 react-navigation TabNavigator?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49010848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com