React native Wix Navigation.push possible unhandled promise rejection: Error : Failed to execute stack command
Login.js
signUpLink =(screenName) => {
Navigation.push(this.props.componentId, {
component: {
name: screenName,
}
});
}
<TouchableOpacity style={styles.buttonText} onPress={this.signUpLink('videostreme.SignUpScreen')}>
<Text style={styles.signUpText} >First time here?? Sign Up</Text>
</TouchableOpacity>
index.js
Navigation.registerComponent('videostreme.LoginScreen', () => Login);
Navigation.registerComponent('videostreme.MainScreen', () => Main);
Navigation.registerComponent('videostreme.SignUpScreen', () => SignUp);
Navigation.registerComponent('videostreme.SplashScreen', () => Splash);
Navigation.events().registerAppLaunchedListener(() => {
Navigation.setRoot({
root: {
stack: {
children: [
{
component: {
name: 'videostreme.MainScreen'
}
},
]
}
}
})
})
How to handle this promise (Navigation.push), anyone have idea about this ??
It is working when I gave componentId directly instead of this.props.componentId (this is undefined when I console it). So I directly give componentId,
redirectPageHandler = screenName => {
Navigation.push('login', {
component: {
name: screenName
}
});
}
The reason why this.props.componentId is undefined is, we need to pass the props from parent component.
My child component is Login and parent component is App
App.js
render() {
return (
<Login {...this.props} />
)
}
Now, we can use this.props.componentId in the child component
Login.js
redirectPageHandler = screenName => {
Navigation.push(this.props.componentId, {
component: {
name: screenName
}
});
}