react-native - React Native Router Flux 道具不通过动作
问题描述
我正在尝试从我的按钮传递一些数据
<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 时,我得到了未定义。
解决方案
嗨,尝试在第二个屏幕键之前添加 _
onPress={() => Actions._dashboard({
demoMode: true,
})}
类似的东西,但如果它不起作用删除你的节点模块文件夹更改路由器通量版本,再次npm i,你会没事的
推荐阅读
- python-3.x - Python 3.东西。带余数的算术函数
- bison - 这个语法有什么问题?
- excel - 混搭资源页面阅读器不可用 - 错误
- python - 在 PyQt5 中动态更改 GUI 元素?
- automation - 如何在单元格中插入公式?
- c# - 'collection[Edm.String(Nullable=True,DefaultValue=,MaxLength=,Unicode=,FixedLength=)]' 类型的值无法转换为字符串
- google-apps-script - 多列上的 Google 表格自动日期和时间戳
- c# - 如何在 Asp.Net Core 2.0.1 中配置用户密码?
- postgresql - PostgreSQL Insert into with case and concat
- reactjs - 传递道具 React Router