Reactjs 在本机导航中传递参数
我对react native和react navigation不太熟悉。如何在导航器之间传递参数?i、 e.从中传递一些参数 导航ORA到导航ORB的另一个屏幕 有关我的导航器设置,请参见下文Reactjs 在本机导航中传递参数,reactjs,react-native,react-navigation,Reactjs,React Native,React Navigation,我对react native和react navigation不太熟悉。如何在导航器之间传递参数?i、 e.从中传递一些参数 导航ORA到导航ORB的另一个屏幕 有关我的导航器设置,请参见下文 const MobileNumberEntryStack = StackNavigator({ MobileNumberEntry: MobileNumberEntryScreen }); const AuthStack = StackNavigator({ SignIn: Si
const MobileNumberEntryStack = StackNavigator({
MobileNumberEntry: MobileNumberEntryScreen
});
const AuthStack = StackNavigator({
SignIn: SignInScreen,
SignUp: SignUpScreen
});
const AppNavigator = SwitchNavigator({
Loading: LoadingScreen,
App: TabNavigator,
Auth: AuthStack,
MobileNumberEntryStack: MobileNumberEntryStack,
});
export default AppNavigator;
在我的加载屏幕中
我正在获取一些数据,然后通过调用
`this.props.navigation.navigate('MobileNumberEntryStack', { user` })
但我没有让用户进入
MobileNumberEntryScreen
。有人能帮我吗?你可以访问你用这个.props.navigation.navigate('ScreenName',{user})
发送的变量,像这样这个.props.navigation.state.params.user
应该可以。你可以访问你用这个.props.navigation.navigation.navigate('ScreenName',{user})发送的变量
像这样这个.props.navigation.state.params.user
应该可以工作。您可以使用这个代码从Navigator发送参数:
this.props.navigation.navigate('Details', {
itemId: 86,
otherParam: 'anything you want here',
});
并使用此代码在NavigatorB中接收参数:
const { navigation } = this.props;
const itemId = navigation.getParam('itemId', 'NO-ID');
const otherParam = navigation.getParam('otherParam', 'some default value');
您可以使用以下代码从NavigatorA发送参数:
this.props.navigation.navigate('Details', {
itemId: 86,
otherParam: 'anything you want here',
});
并使用此代码在NavigatorB中接收参数:
const { navigation } = this.props;
const itemId = navigation.getParam('itemId', 'NO-ID');
const otherParam = navigation.getParam('otherParam', 'some default value');
将以下代码添加到AppNavigator中,然后尝试导航到其中
MobileNumberEntryStack: {
screen: MobileNumberEntryStack,
},
将以下代码添加到AppNavigator中,然后尝试导航到其中
MobileNumberEntryStack: {
screen: MobileNumberEntryStack,
},
您可以显示MobileNumberEntryScreen吗?请共享MobileNumberEntryScreen。了解redux。您可以显示MobileNumberEntryScreen吗?请共享MobileNumberEntryScreen。了解redux。当我登录时,控制台。日志(“@Param”,this.props.navigation.state.params);在NavB中,我得到unfinedtry console.log(“@Param”,otherParam);在里面NavB@param:undefined:/,在记录console.log(“@Param”,this.props.navigation.state.params)时不使用默认值;在NavB中,我得到unfinedtry console.log(“@Param”,otherParam);在里面NavB@param:未定义:/,不使用默认值