我有一個註冊表單,用戶註冊後,它將重定向到用戶輸入通過電子郵件發送的確認碼的電子郵件確認頁面(/確認)。當用戶提交確認碼時,我想將代碼和用戶的電子郵件發送到服務器端。如何在React中重定向到其他路線時傳遞狀態/道具?
我的申請表單的代碼(簡化):
constructor(props){
super(props);
this.state = {
email: '',
password: '',
errors: {},
}
}
handleSubmit(e){
e.preventDefault();
this.props.userSignup(this.state).then(
() => {
this.context.router.push({
pathname: '/confirmation'
})
},
)
}
render(){ ...
我不想任何PARAMS添加到我的路徑。
如何將this.state.email
傳遞給確認頁?
使用反應路由器https://github.com/ReactTraining/react-router –