繁体   English   中英

从redux状态更新本地状态?store.subscribe没有被调用以更新stepzilla中的步骤

[英]Update local state from redux state?store.subscribe is not getting called to update step in stepzilla

我必须使用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之后没有被调用?

提前致谢。

什拉达

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM