【发布时间】:2019-01-29 09:32:40
【问题描述】:
我使用 react-stepzilla 开发了多步骤注册表单。我在此注册中使用了 react 和 redux。
我需要验证这些步骤,我按照这些步骤将验证添加到步骤中
我在步骤中添加了 isValidated 函数。
它在 react 中工作,但在 redux 中无法使用 react 可能是 react-stepzilla 是 HOC 的问题。
我遵循了 react-stepzilla 模块 git 解决方案,但出现错误 "main.js:318 Uncaught TypeError: Cannot read property 'isValidated' of undefined"
//React stepzilla main component
const steps = [
{ name: 'step1', component: <RegistrationType /> },
{ name: 'step2', component: <PersonalDetails /> },
{ name: 'step3', component: <ContactDetails /> }
]
class MultiStep extends Component {
render() {
return (
<Fragment>
<h1 className="page-header">Register for New Account</h1>
<StepZilla
steps={steps}
stepsNavigation={true}
nextButtonText='Save and Continue'
backButtonText='Back'
nextButtonCls="btn btn-warning active pull-right mr-0"
backButtonCls="btn btn-primary pull-left ml-25"
hocValidationAppliedTo= {[0,1, 2]}
/>
</Fragment>
);
}
}
//Step1 Component:
// Checking the validation for registration
isValidated(){
alert("checking isValidated calling")
return this.state.count > 2
}
// connecting with redux
export default connect((state) => ({register_reducer: state.register_reducer.register_user}),{saveUser})(Step1); //This is not working and getting the error
//connecting without redux
export default Step1 // this is working and checking the validation part
当我们与 redux 连接时,我收到错误“无法读取未定义的属性 'isValidated'”。
请帮我解决这个问题。
【问题讨论】:
标签: reactjs redux react-stepzilla