后退按钮转到堆栈的初始路径,而不是前一个屏幕

时间:2017-07-19 22:16:23

标签: react-native react-navigation

考虑以下路线:

const App = TabNavigator({
    Home: {
        screen: HomeScreen
    },
    Settings: {
        screen: SettingsStack
    }
})


const SettingsStack = StackNavigator({
    SettingsMenu: {
        screen: SettingsMenuScreen
    },
    AccountSettings: {
        screen: AccountSettingsScreen
    }
})

HomeScreen看起来像这样:

function HomeScreen ({ navigation }) {
    return (
        <View>
            <Button
                title=’Go to Account Settings’
                onPress={() => navigation.navigate(‘AccountSettings’)}
            />
        </View>
    )
}

当我按下HomeScreen中的按钮时,该应用会导航至AccountSettings。但是,当我点击AccountSettings&#39;中的后退按钮时标题,应用导航到SettingsMenu。我希望它能回到Home

什么应该是正确的行为?无论如何,我可以让它回到它的屏幕,而不是堆栈的初始路线?

我已经在GitHub中创建了一个repo来重现这个:https://github.com/Sparragus/react-navigation-issue

这是该应用的截屏视频:http://recordit.co/tjQxbVcgtr

0 个答案:

没有答案