Josh
Josh

Reputation: 1062

React-native How can I force TabNavigator's child to re-render in TabNavigator?

My code is Here

I'm using react-navigation TabNavigator, StackNavigator
I want a component to be re-rendered EVERY TIME I navigate to it.
But it was rendered only ONCE when I navigate to it.

How can I force TabNavigator's child to re-render in TabNavigator?

Upvotes: 0

Views: 589

Answers (1)

Kraylog
Kraylog

Reputation: 7563

You can set new parameters when navigating to the screen. This causes react-navigation to invoke a render.

Here's an example from the react-navigation docs:

 <Button
      onPress={() => navigate('Profile', {name: 'Brent'})}
      title="Go to Brent's profile"
    />

the second parameter to navigate is a params object. If you put something random there, it will cause a render every time you call it.

Upvotes: 2

Related Questions