benevbright/react-navigation-collapsible

Headerbar does not rerender after changing options

Ghoul2077 opened this issue · 1 comments

Information

  • react-native version: 0.63 (Expo 41)
  • react-navigation version: 5
  • react-navigation-collapsible version: 5.9.1
  • Platform (iOS/Android): Android
  • react-native init or Expo: Expo

Detail

When options are update the hook does not re-render the header after the first mount. In my case the property that I am trying to update is headerRight for navigationOptions .
Vanilla react navigation seems to handle this as expected that is updates the header bar when options are updated in useEffect.

Here is a snack showing this issue
https://snack.expo.io/@mark11/intrigued-cheese

Well I am gonna close the issue as I found a way around it , here is how I fixed it ->

I used

useLayoutEffect(() => {
    navigation.setOptions({
      headerRight: () => ( your dynamic component here ),
    });
  }, [navigation]);

while leaving all dynamic options out of react-navigation-collapsible config object