3

I'm using react-native-navigation and using redux for state management. when I go to screenA to screenB with "push" method and the screenA won't unmount. this will cause unwanted rerenders and previously in react-navigation I used shouldComponentUpdate to match component with the currently visible screen to stop re-render.

Is there a way to do this in react-native-navigation?

TIJ
  • 2,771
  • 3
  • 19
  • 32

1 Answers1

2

When you set a navigator events handler (using addOnNavigatorEvent) you can track screen lifecycle events and get notified when a screen disappears or appears.

Alternatively you can check if the screen is currently visible using await this.props.navigator.screenIsCurrentlyVisible(), though i'm not sure what are the implications of doing this in shouldComponentUpdate since it performs a native call which needs to cross the bridge and might add unnecessary delays.

You can see more about screen visibility here.

Artal
  • 8,933
  • 2
  • 27
  • 30