小编Gho*_*ngy的帖子

TabNavigator中的React Navigation传递道具

我有在初始屏幕上从服务器加载的道具.我想将它们传递给其他选项卡屏幕.但是,我没有在网上找到任何例子.我知道screenProps,但不知道如何设置它.我尝试过的所有方法都导致了错误.

const EProj = TabNavigator({
  Home: { screen: HomeScreen },
  Map: { screen: MapG },
  Login: { screen: Login },
  Profile: { screen: Profile },
}, {
  tabBarPosition: 'bottom',
  animationEnabled: true,
  tabBarOptions: {
    activeTintColor: '#1abc9c',
  },
});
Run Code Online (Sandbox Code Playgroud)

这是我的屏幕设置.我应该在哪里放置screenProps?

<EProj
  screenProps={cats}
/>
Run Code Online (Sandbox Code Playgroud)

如何设置它的任何好例子都会有所帮助.提前致谢.

HomeScreen设置:

class HomeScreen extends React.Component {
  static navigationOptions = {
    tabBarLabel: 'Home',
  };

...

  componentWillMount(){
    console.log("Starting to load assets from server!");
    this.onLoadCats(); /*starts asset loading*/
  }

  render() {
    return (
      <View style={styles.container}>

        <Text>Welcome to alpha 1.17 This is …
Run Code Online (Sandbox Code Playgroud)

javascript android react-native react-navigation

13
推荐指数
1
解决办法
1万
查看次数