0

How do we pass props or params to a tab navigation component. So for I tried the follow but no luck

I am trying to send the param or prop to the component HomeTab

<Tab.Navigator>
    <Tab.Screen name="Home" component={HomeTab} MyParam='custom message' />
    <Tab.Screen name="Video" component={VideoTab} />
</Tab.Navigator>
Jerry Seigle
  • 417
  • 4
  • 12
  • maybe this could help you : https://stackoverflow.com/questions/60439210/how-to-pass-props-to-screen-component-with-a-tab-navigator – Matteo Jan 07 '21 at 16:02

1 Answers1

0
<Tab.Navigator>
    <Tab.Screen name="Home" component={()=> <HomeTab MyParam='custom message'/>} />
    <Tab.Screen name="Video" component={VideoTab} />
</Tab.Navigator>

Here is another way using context API: How to pass props to Screen component with a tab navigator?

Ketan Ramteke
  • 10,183
  • 2
  • 21
  • 41
  • Works but introduced a new issue. Looks like you're passing an inline function for component prop for the screen. may cause state lose on re-rendering and cause perf issues – Jerry Seigle Jan 07 '21 at 16:17
  • 1
    I know it's not a right approach ,that's why I also provided one workaround using Contex API in a link given. – Ketan Ramteke Jan 07 '21 at 16:21