【问题标题】:React Native Router Flux props not passing through actionReact Native Router Flux 道具不通过动作
【发布时间】:2019-03-07 13:57:03
【问题描述】:

我正在尝试从我的按钮传递一些数据

   <Button
                text="Explore"
                elementStyles={secondaryButton}
                onPress={() => Actions.dashboard({
                  demoMode: true,
                })}
                testID="button-explore"
              />

位于 Example.js 中的 Dashboard.js

这是我位于 App.js 下的路由器堆栈

<Stack key="root" hideNavBar>
              <Scene key="splash" initial component={SplashScreen} />
              ....
              <Scene key="example" component={example} />
              ....

              <Tabs key="tabbar" hideNavBar tabBarPosition="bottom" showLabel={false} tabBarStyle={styles.tabBar} swipeEnabled={false} animationEnabled={false}>
                <Scene key="dashboard" hideNavBar title="Dashboard" component={Dashboard} icon={TabBarItem} defaultIcon={Config.HOME_ICON_NAME} />
                <Scene key="history" hideNavBar title="Stats" component={History} icon={TabBarItem} defaultIcon={Config.STATS_ICON_NAME} />
                <Scene key="rewards" hideNavBar title="Points" component={Rewards} icon={TabBarItem} defaultIcon={Config.REWARDS_ICON_NAME} />
                <Scene key="profile" hideNavBar title="Profile" component={Profile} icon={TabBarItem} defaultIcon={Config.PROFILE_ICON_NAME} />
              </Tabs>
 />

            </Stack>

当我在仪表板下调用 this.props.demoMode 时,我得到了未定义。

【问题讨论】:

    标签: react-native react-native-router-flux


    【解决方案1】:

    你好尝试在第二个屏幕键之前添加_

    onPress={() => Actions._dashboard({
                  demoMode: true,
                })}
    

    类似的东西,但如果它不起作用,请删除您的节点模块文件夹更改路由器通量版本,再次 npm i,您会没事的

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-08
      • 1970-01-01
      • 2017-08-25
      • 2018-08-25
      相关资源
      最近更新 更多