This ES6 is giving some problems in React native. I want to write the code in pure ES6 but writing the part is giving errors.
ES5 code
renderScene: function (route, navigator) {
var Component = route.component;
return (
<Component openModal={() => this.setState({modal: true})}/>
)
},
Where the ES6 is:
renderScene(route, navigator) {
var Component = route.component;
return (
<Component openModal={() => this.setState({modal: true}) }/>
)
}
I am getting this error:
I have tried to add bind(this) but it doesnt work.
Can anyone please help? Thx in advance
EDIT: Added full class code
class Navigation extends Component {
constructor(props) {
super(props)
this.state = {
modal: false,
}
}
renderScene(route, navigator) {
var Component = route.component;
return (
<Component openModal={() => this.setState({modal: true}) }/>
)
}
goToOtherRoute() {
//this.refs.navigator.push({newRoute})
}
render() {
return (
<View style={styles.container}>
<Navigator
ref="navigator"
initialRoute={RouteStack.app}
renderScene={this.renderScene}
/>
{this.state.modal ? <Basket goToOtherRoute={this.goToOtherRoute} closeModal={() => this.setState({modal: false}) }/> : null }
</View>
);
}
}