【发布时间】:2023-03-05 16:19:01
【问题描述】:
我仍然是反应导航的新手。 我希望在登录成功后重置路线信息。但是有一些参数,比如我希望传递给主页的登录信息。
import { NavigationActions } from 'react-navigation'
const resetAction = NavigationActions.reset({
index: 0,
actions: [
NavigationActions.navigate({ routeName: 'Profile',
params:{user:this.state.username}})
]
})
this.props.navigation.dispatch(resetAction)
在个人资料页面中,我想访问参数,所以我使用这个:
constructor(props){
super(props)
this.state = { username: this.props.navigation.state.params.user,
}
但我收到:undefined is not an object (evaluate '_this.props.navigation.state.params.user') 在控制台日志中。 我可以知道我应该如何获取参数吗?谢谢
【问题讨论】:
标签: react-native react-navigation