Replace All Screens in React Navigation

Tiempo de lectura: < 1 minuto

Reading Time: < 1 minute

To replace all screens in React Navigation (@react-navigation/native-stack) and load a single screen, we need to add the following code:

navigation.reset({
    index: 0,
    routes: [{ name: 'Menu' }],
});

First, we get the navigation hook from a native-stack and apply a reset. We specify the starting point (index: 0) and the route we want to load (routes: [{ name: ‘Menu’ }]).

Leave a Comment