Depending on if a screen exists in a certain stack I need to be able to do different things in my code. I have tried my best but I haven't found anything on the matter. Is there an easy way to achieve this?
In v.6 :
const navigation = useNavigation();
const routes = navigation.getState().routeNames;
If you mean, you want to get all the routes inside the current navigator, then I think this will fix your problem.
const navigation = useNavigation();
const routes = navigation.dangerouslyGetState().routeNames;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With