I can not update the status of my App.js with the current page when Navigator executes its pop method in React-Native (0.26).
I update the status with the function
goto.
_goto(currentPage, scene) {
this.setState({currentPage});
this._navigator.push({
id: currentPage,
});
}
This is the function that renders scenes in the Navigator.
_renderScene(route, nav) {
curPage = route.id;
switch (route.id) {
...
}
Teng ona function that runs when I press the back button on Android.
_patras(){
if(curPage != 'MainPage' && curPage != 'SplashPage'){
this._navigator.pop();
return true;
}
}
And this is the render method of my App.js where I have the TabBar.
var currentPage = this.state.currentPage;
if (currentPage != 'SplashPage'){
if (this.isAndroid){
TBar = (<TabBar goto={(page) => this._goto(page)} currentPage={currentPage}/>);
} else {
TBar = (<TabBarIOS goto={(page) => this._goto(page)} currentPage={currentPage}/>);
}
}
I use the current page to change the style and disable the TabBar button that corresponds to it. With this code it works well for me if I move forward but when I turn back it does not update me since I can only take it through the goto. If I put a this.setState in the renderScene method the application is blocked.
What would be the best way to do it?