我尝试了一个React Native Navigator的例子:
const StudentStackNav = StackNavigator({
Home: {
screen: StudentLogin,
}
});
如何将参数传递给StudentStackNav并将其传递给StudentLogin?
我尝试使用<StudentStackNav name='Lucy'>
,但是this.props.name
在Home
中不可用。
我尝试了一个React Native Navigator的例子:
const StudentStackNav = StackNavigator({
Home: {
screen: StudentLogin,
}
});
如何将参数传递给StudentStackNav并将其传递给StudentLogin?
我尝试使用<StudentStackNav name='Lucy'>
,但是this.props.name
在Home
中不可用。
Navigator组件上的普通props可用于配置导航器。
要向屏幕发送任意props,必须使用screenProps
。
因此,例如:
<StudentStackNav screenProps={{ name: 'Lucy' }}/>
将在StudentLogin
中作为this.props.screenProps
可用。
screenProps
在此页面上有记录。
class Foo extends Component {
constructor(props)
{
super(props);
props.screenProps // what you want to access
}
render() {
return null;
}
}
- user883210