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

前端 未结 13 2449
终归单人心
终归单人心 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:08

    This works fine as of now:

    import { NavigationActions, StackActions } from 'react-navigation'
    
    resetStack = () => {
            const navigateAction = NavigationActions.navigate({
                routeName: 'Home',
    
                params: {},
    
                action: NavigationActions.navigate({ routeName: 'Home' }),
            });
    
            props.navigation.dispatch(navigateAction);
        }
    

    Found here in the docs: https://reactnavigation.org/docs/en/navigation-actions.html#reset

提交回复
热议问题