Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 在本机导航中传递参数_Reactjs_React Native_React Navigation - Fatal编程技术网

Reactjs 在本机导航中传递参数

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

我对react native和react navigation不太熟悉。如何在导航器之间传递参数?i、 e.从中传递一些参数

导航ORA到导航ORB的另一个屏幕

有关我的导航器设置,请参见下文

    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:未定义:/,不使用默认值