Reputation: 6142
I'm trying to navigate from login screen to home screen on submit button
click...
Following is my fucnction for navigation
onsubmitButtonPress(event)
{
if(User != null && password != null){
if(User != '' && password != ''){
if (User == password){
ToastAndroid.show('Login Successful', ToastAndroid.SHORT);
this.props.navigator.push({
title: 'Home',
component: HomeScreen,
});
}else{
ToastAndroid.show('Login Failed', ToastAndroid.SHORT);
}
}else{
ToastAndroid.show('Fill details', ToastAndroid.SHORT);
}
}else{
ToastAndroid.show('Fill details', ToastAndroid.SHORT);
}
}
But I'm getting this error.Can anybody help me out..
Upvotes: 0
Views: 2106
Reputation: 12730
The problem is likely how you're calling onsubmitButtonPress
. Change where you set it on your component from this:
someProp={this.onsubmitButtonPress}
to this:
someProp={(e) => this.onsubmitButtonPress(e)}
The issue being that this
is not defined.
If it's NOT that, then it's likely that you're never defining this.props.navigator
. Put a breakpoint (or a console.log) in your function there to log the value of this.props
and check if it exists, and if it does, if this.props.navigator
is defined on it.
Upvotes: 1