Resetting the navigation stack for the home screen (React Navigation and React Native)

前端 未结 13 2392
终归单人心
终归单人心 2020-11-29 23:49

I\'ve got a problem with the navigation of React Navigation and React Native. It is about resetting navigation and returning to the home screen.

I\'ve build a StackN

13条回答
  •  抹茶落季
    2020-11-30 00:13

    Just mix the two solutions given above and this will work just fine, basically we have to use StackActions and key: null. Without using StackActions, it was throwing some error

    import { NavigationActions, StackActions } from 'react-navigation';
    const resetHandler = () => {
            props.navigation.dispatch(StackActions.reset({
                index: 0,
                key: null,
                actions: [NavigationActions.navigate({ routeName: 'PatientDetails' })]
            }))
        };
    

提交回复
热议问题