Replacing all Screens in React Navigation

Tiempo de lectura: < 1 minuto

Reading time: < 1 minute

To replace all screens of React Navigation (@react-navigation/native-stack) and load only one, we need to add the following code:

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

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

Leave a Comment