React-native-tab-view: how to pass props when using the 'SceneMap' helper

Created on 18 Jul 2017  路  2Comments  路  Source: satya164/react-native-tab-view

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?

Most helpful comment

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.

All 2 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

satya164 picture satya164  路  3Comments

compojoom picture compojoom  路  4Comments

f6m6 picture f6m6  路  3Comments

glennvgastel picture glennvgastel  路  3Comments

moerabaya picture moerabaya  路  4Comments