React Answers

How to pass params to tab navigator React Navigation 5?

Spread the love

To pass params to tab navigator React Navigation 5, we create a context and set put the value we want in the context.

Then any component inside the context provider can access the value.

For instance, we write

export const NetworkContext = React.createContext();

to create the NetworkContext and export it.

Then we write

const PostsTabNav = createMaterialTopTabNavigator();

const PostsMainNav = ({ route }) => {
  return (
    <NetworkContext.Provider value={}>

to create the PostsTabNav with createMaterialTopTabNavigator.

And then we wrap NetworkContext.Provider around the PostsTabNav components and set the context value to

Then the PostsTabNav components can access with the context.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *