reactjs - 如何在 StackActions 中发送参数 - React Native
问题描述
我正在尝试使用StackActions
. 页面导航成功,但没有收到相应的已发送参数。
主屏幕:
reLogin = () => {
this.props.navigation.dispatch(StackActions.reset({
index: 0,
actions: [
NavigationActions.navigate({
routeName: 'Login'
},
{
forceLogin: true <<-- This Flag Is Set Here
}),
],
}))
}
登录屏幕:
没有错误,但在LoginScreen
'scomponentDidMount()
中,下面的代码总是返回 false。
componentDidMount() {
alert(this.props.navigation.getParam('forceLogin', false))
}
我错过了什么?
解决方案
从文档中,您需要传递参数对象,例如,
NavigationActions.navigate({
routeName: 'Login',
params : { forceLogin: true }
})
推荐阅读
- monitoring - 如何从一段时间内获取 Couchbase 节点统计信息的样本
- tampermonkey - 如何获取网页中包含的文本并将其作为页面标题的一部分?
- apache-spark - 在配置单元表中交换分区时出错
- javascript - 使用 SELECT 附近的 sql sintaxis 出错,代码:'ER_PARSE_ERROR',errno:1064
- syntax - 在 OCaml 中,如何区分 * 和 ,?
- python-3.x - 如何解决错误“ValueError:时间数据'2019-07-01 07:00:00'与格式'%y-%m-%d %H:%M:%S'不匹配”
- java - 什么是hashmap入口类中的hashcode和equals
- javascript - 浏览器游戏保护
- r - 如何从R中的XML父节点中解析信息
- android - 由于违反垃圾邮件政策,我的 APP 被暂停