When using this renderScene like below, it's easy to pass both the 'route' object and the 'focused' boolean, like so:
renderScene = ({ route,focused }) => {
switch (route.key) {
case '0':
return (
<SimplePage
state={this.state}
style={{ backgroundColor: Colors.purple }}
focused={focused}
tabRoute={route}
/>
)
case '1':
return (
<SimplePage
state={this.state}
style={{ backgroundColor: Colors.purple }}
focused={focused}
tabRoute={route}
/>
)
default:
return (
<View style={{...Views.middle}}>
<Text>Tab Failed to Load</Text>
</View>
)
}
}
but if i want to pass the 'route' object and 'focused' boolean using the 'SceneMap' helper instead of the function above, what's the syntax for doing that?
The route object is already passed when you use SceneMap. If you want to pass a focused prop, then you will have to stick with the current way. SceneMap doesn't allow such props to stay performant.
There is a new way of doing this by using the React context API, more info: https://reactjs.org/docs/context.html
Most helpful comment
The
routeobject is already passed when you useSceneMap. If you want to pass afocusedprop, then you will have to stick with the current way.SceneMapdoesn't allow such props to stay performant.