Reputation: 489
I have trouble using the react-navigation like stack navigation with drawer navigation
const Drawerstack = DrawerNavigator({
updatesegregation : { screen: UpdateSegregation },
listoffers : { screen: ListOffers },
mypurse : { screen: MyPurse },
myoffers : { screen: MyOffers },
segregationhistory : { screen: SegregationHistory },
ranking : { screen: Ranking },
updates : { screen: Blogs },
contactus : { screen: ContactUs },
termsandconditions : { screen: TermsAndConditions },
instruction : { screen: Instructions },
profile : { screen: Profile },
segregationtips : { screen: SegregationTips },
faqs : {screen: Faqs },
},{
contentComponent: NavigationDrawer,
})
const Index = StackNavigator({
authcheck : { screen: AuthCheck },
login: { screen: Login },
registration : { screen: Registration },
profileedit : { screen: ProfileEdit },
socialregistration : { screen: SocialRegistration },
forgotpassword : { screen: ForgotPassword },
drawerstack: { screen: Drawerstack },
},
{
headerMode: 'none'
});
export default Index;
the root page is authcheck which checks the access token and return the user.
fetch(url.main + 'version' + url.transform, {
method: 'GET',
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
}).then((response) => response.json())
.then((responseData) => {
//alert(JSON.stringify(responseData))
if(responseData.version[0].version_code == Version){
AsyncStorage.getItem('User').then((value) => {
//alert(JSON.parse(value));
var tmpValue = JSON.parse(value);
if (tmpValue !== null) {
this.props.navigation.navigate("updatesegregation");
}else{
this.props.navigation.navigate('login');
}
})
}else{
this.PopupDialog.show();
}
})
But when there is access token availabe then it didn't show any error an also it didn't navigate to the requested page.
This navigation is not redirecting me to the page i want from the DrawerNavigator...
if anyone knows please help...
Upvotes: 0
Views: 721
Reputation: 141
This is due to reference
this.prop
create a global function
onAuthentication = (screenName) =>{
this.props.navigation.navigate(screenName)
};
and then call this function inside ur fetch function like
this.onAuthentication('updatesegregation') or this.onAuthentication('login')
Upvotes: 1