我必须使用redux状态来维护stepzilla中的步骤状态。
class MainWizard extends React.Component {
constructor(props) {
super(props);
this.state = {
CurrentWizardStep : 0,
};
store.subscribe(() => {
console.log('Inside subscribe')
this.setState({
CurrentWizardStep : store.getState().selectedWizradStep
});
});
}
render() {
const steps =
[
{ name: 'step1', component: <step1/> },
{ name: 'step2', component: <step2 /> },
{ name: 'step3', component: <step3 /> },
];
return (
<article className='step-progress'>
<StepZilla
steps={steps}
preventEnterSubmission={true}
nextTextOnFinalActinonStep={'Save'}
hocValidationAppliedTo={[3]}
//startAtStep={window.sessionStorage.getItem('step') ? parseFloat(window.sessionStorage.getItem('step')) : 0}
startAtStep = {this.state.CurrentWizardStep}
//onStepChange={(step) => window.sessionStorage.setItem('step', step)}
showNavigation={false}
/>
</article>
);
}
}
redux状态正在进行更新,但在调度后,store.subscribe没有被调用?
提前致谢。
Shraddha