0

I have a react native App. I'll like to detect navigation to screens, so when I navigate to a specific screen I trigger a update function. I have the componentDidMount but works only when navigating for the first time... Also have looked at AppState but do not monitor navigation between screen, how should I do it?

Thanks

Marco Martin
  • 185
  • 1
  • 4
  • 18

1 Answers1

1

you can use the hook useFocusEffect from react navigation.

Sometimes we want to run side-effects when a screen is focused. A side effect may involve things like adding an event listener, fetching data, updating document title, etc. While this can be achieved using focus and blur events, it's not very ergonomic.

docmurloc
  • 1,201
  • 4
  • 11