Reputation: 3081
I have the following Tab Navigator:
const [counter, setCounter] = useState(10);
return (
<Tab.Navigator>
<Tab.Screen name="Activity" />
</Tab.Navigator>
);
How can I pass my "counter" state to the Tab Screen as route param?
Note: The counter can change, it is just a value listened from my database.
Upvotes: 0
Views: 388
Reputation: 9845
The simplest way to do it is like this:
const [counter, setCounter] = useState(10);
return (
<Tab.Navigator>
{() => <Tab.Screen name="Activity" counter={counter}/>}
</Tab.Navigator>
);
I have created a working snack for you: https://snack.expo.io/@abranhe/react-navigation-5
Upvotes: 2