无法从自定义导航器导航

时间:2019-03-20 05:52:30

标签: react-native react-native-android react-navigation react-navigation-stack

因此,我有一个自定义导航器,可用于向后滑动导航。 另外,对于某些真正的原因,我也很抱歉张贴图片并且不粘贴代码。希望您能查看图片。

下面是自定义导航器的代码。 https://gist.github.com/shubham6996/985568f49b2511dec2438c624fe259d0

const SwipeMainStack = () => {
    return(
        <Navigator>
            <Route name="LoggedOutHome" component={LoggedOutHome} />
            <Route name="SignUp" component={SignUp} />
            <Route name="EmailAuth" component={EmailAuth} />
            <Route name="Login" component={Login} />
            <Route name="EmailLogin" component={EmailLogin} />
            <Route name="EmailSignUp" component={EmailSignUp} />
            <Route name="SignupUsername" component={SignupUsername} />
        </Navigator> 
    );
}

const stack = createStackNavigator({
    SwipeStack: {screen: SwipeMainStack},
    TabHolder: {screen: TabHolder},
}, {
    initialRouteName: 'SwipeStack',
    headerMode: 'none',
});

export default createAppContainer(stack);

下面是LoggedOutHome屏幕 enter image description here

以下是“注册”屏幕 enter image description here

下面是EmailSignUp屏幕 enter image description here

下面是EmailLogin屏幕 enter image description here

导航是这样的,当我导航到SignUp屏幕时,它将带我到EmailSignUp,然后将我带到EmailAuth

我可以使用LoggedOutHomeEmailAuth导航到this.props.navigator.push('SignUp')屏幕,但不能从EmailAuth导航到SignUp

1 个答案:

答案 0 :(得分:0)

如果您像下面那样定义SwipeMainStack,那么它应该可以工作。

const SwipeMainStack = createStackNavigator({
    LoggedOutHome: LoggedOutHome,
    SignUp: SignUp,
    EmailAuth:EmailAuth
    Login:Login
    EmailLogin:EmailLogin
    EmailSignUp:EmailSignUp
    SignupUsername:SignupUsername

})



const stack = createStackNavigator({
    SwipeStack: SwipeMainStack
    TabHolder: TabHolder,
}, {
    initialRouteName: 'SwipeStack',
    headerMode: 'none',
});

export default createAppContainer(stack);