My React navigation version has just upgraded from v4 to v5.
Here is my nested navigation :
Stack Navigation
Main (Tab.Navigator)
- home (Stack Navigation)
- screen A (initial route screen)
- screen B (screen)
- settings (Stack Navigation)
- home (Stack Navigation)
Web (Tab.Navigator)
I have put a language switch button in screen A headerRight() and handle the language state with react-redux.
this.props.navigation.setOptions({
title: I18n.t("ScreenA"),
headerRight: () => (< LangSwitchButton />),
})
In tabNavigator.js,
< Tab.Screen
name="TabA"
component={homeScreen}
options={tabBarLabel: I18n.t("tabA")}
listeners={({ navigation, route }) => ({navigation.navigate("home"))}
/>
In navigation v4, the language can be switched in real time with static navigationOptions. But in navigation v5, this.props.navigation.setOptions
cannot update the state of tabBarLabel. Only tap to other screen and back to the screen A can update the language state.
My current approach is to put this.props.navigation.setOptions
part inside render(), language switch works for the header and main content, but the language of the tabBarLabel still not updated in real-time.
Is there any ways to update the tabBarLabel through setOptions in screen level?
Thank you.