导航stackNavigator与onSubmit函数



导航到另一个屏幕,同时提交信息:handleSubmit方法如下:

<View style={CreditRegStyle.button}>
<Button
style={CreditRegStyle.button}
title="Sign Up!"
onPress={this.handleSubmit}
/>
</View>
export default class CreditRegister extends Component  {
handleSubmit = () => {
const value = this._form.getValue();
console.log('value: ', value);
}

render() {
return (
<>

如果您正在使用react-navigation模块,您可以在handlessubmit方法中提交您的信息,并在方法的末尾调用this.props.navigation.navigate(...),如这里所述:https://reactnavigation.org/docs/connecting-navigation-prop

你的代码应该是这样的:
export default class CreditRegister extends Component  {
handleSubmit = () => {
const value = this._form.getValue();
try {
await submitYourInformation(value);
} catch (e) {
console.log(e);
}   

this.props.navigation.navigate(screenName);
}

render() {
return (
<>

最新更新