【发布时间】:2021-03-08 01:30:13
【问题描述】:
我正在尝试将用户名从注册 1 传递给注册 2:
handleSignUp = () => {
console.log(this.state.username) <------------- This logs correctly
try {
this.props.navigation.navigate('Signup2', {
username: this.state.username, <------------- Passing here
});
} catch (error) {
console.log(error);
}
}
这是来自 Signup2 的代码:
const Signup2 = (props, route, navigation) => {
const { username } = route.params; <----------- Trying to access it here
我收到以下错误:
undefined is not an object (evaluating 'route.params.username')
我也试过这个:
const { username } = props.route.params
两者都不起作用。
如何访问路由参数?
【问题讨论】:
标签: javascript react-native react-navigation