React Navigation: How to trigger navigation.push() in bottom tab navigator?

Viewed 536

Here is what I am trying to do in my app with react navigation:

  1. There is a default bottom tab navigator.
  2. The app will listen to changes in the data.
  3. If there is a change in the data for any of the screens in the bottom tab navigator, trigger navigation.push() to refresh the component.

What I observed is that the default behavior of the bottom tab navigator is navigation.navigate()...i.e. unless I reload the app, the screens do not refresh themselves.

In short, how do I trigger navigation.push() in the tab navigator? e.g. in the sample code below, how do I set the navigation behavior?

Thanks a lot in advance!

//How do I trigger navigation.push() when each of the bottom tab is pressed?
export default function App() {
  return (
    <NavigationContainer>
       <Tab.Navigator>
          <Tab.Screen name="Home" component={HomeStackScreen} />
          <Tab.Screen name="Settings" component={SettingsStackScreen} />
       </Tab.Navigator>
    </NavigationContainer>
  );
}
0 Answers
Related