ios - React Native - Navigate after an async action -


i'm developing mobile app react native , redux , i'm facing software design problem. want call rest api (async operation) login , navigate main view if operation successful. i'm using redux , thunk have async actions implemented main doubt is: should put logic navigate main view?

can access navigator object directly action , perform navigation there? should in login component? (as i'm doing - check code below).

componentwillreceiveprops(nextprops){     if(nextprops.errorloginmsg){         alert.alert("login failed", nextprops.errorloginmsg);     }     else if(!nextprops.user.isnull()){       this.props.navigator.replace({name: 'main'});     }   } 

i'm not confident of having logic in component. not seem practice. there other way this?

thanks

this 1 of hardest problems in react native current navigator api. suggest having route store holds current route , have component includes navigator connected store , having navigation triggered on componentwillreceiveprops.


Comments