How to pass current state of Parent Component to Tab Navigation Screens

I am using “react-native-tab-view”: “^3.0.1”. I want to pass current state from parent component to child component while using react-native-tab-view to render tab screens.

How to pass current state of Parent Component to Tab Navigation Screens
This is an example where I am have had to pass  current state value from parent component to child tab screen components in react native. Its a Events Screen with two child screen so I wanted to pass date to both components to filter events based on date passed from parent Screen component.

Following an answer over stackoverflow it could also be done using children property in
based rendering however.

 

Pass current state to Tab Navigation Screens

But, since I used ScreenMap() method of ReactNative tab view to render my screen and I didn’t want to change that I just discovered an easy method to render screens as component and pass additional properties along with current state, as shown in the code snippet below.


I hope it helps someone.

Leave a Reply