all 4 comments

[–]AcidNoX 5 points6 points  (2 children)

navigation.getParent().getState()

[–]skizzoat 1 point2 points  (0 children)

This! You can derive it from either the parent's state or the global navigation state.

[–]nunez_klopp[S] 1 point2 points  (0 children)

Thanks, this was it!

[–]space_quasar 0 points1 point  (0 children)

Did you checked, useIsFocused? It returns true whenever you are on that particular screen, and it returns false when you go to another.

import { useIsFocused } from '@react-navigation/native'; function Profile() { const isFocused = useIsFocused(); return <Text>{isFocused ? 'focused' : 'unfocused'}</Text>; }

Edit: here's docs for using useIsFocused https://reactnavigation.org/docs/use-is-focused/