【问题标题】:How to pass props to Actions.replace react-native-router-flux如何将道具传递给 Actions.replace react-native-router-flux
【发布时间】:2018-08-25 09:50:40
【问题描述】:
版本
告诉我们您使用的是哪些版本:
react-native-router-flux v4.0.0-beta.28
react-native v0.52.2
尝试了以下...
Actions.replace({ key: tabKey, props: tabPage });
Actions[key]({ type: ActionConst.REPLACE, tabPage: tabPage })
还有几个变体
【问题讨论】:
标签:
reactjs-flux
react-native-router-flux
【解决方案1】:
我会建议尝试最新版本 - 但如果不可能,请移至仍在使用 react-navigation 1.5 的最后一个测试版 - 现在只有该版本的分支 (4.0.0-beta) 然后使用execute 方法。
Actions.execute('replace', tabKey, { tabPage });
而且我相信你展示的两个例子也不正确,但我可能错了,在这个 beta 版本的工作期间更改的数量是巨大的,但根据代码/API 文档,这就是你的方式应该这样做:
Actions.replace(tabKey, { tabPage });
// or
Actions[tabKey]({ tabPage }); // and use type={ActionsConst.REPLACE} on your `Scene`
【解决方案2】:
你最常使用Actions.replace('tab name'); 和这项工作