简体   繁体   中英

redux-form dynamic name does not change the reducer name

I'm using a redux-form like this:

 <RenderForm
      form={form.name}
      elements={form.elements}
      initialValues={form.initialValues}
      method={form.method}
      target={form.target}
      validate={parseValidations(form.elements)}
      enableReinitialize
      keepDirtyOnReinitialize
      {...props}
    />

and

const RenderForm = reduxForm()(Form);

and

const Form = ({ children, method, target, form, elements, msg, handleSubmit, onChange }) => (
  <form
    onSubmit={handleSubmit}
    id={form && `form-${form}`}
    method={method}
    action={target}
    onChange={onChange}
  >
    { msg ? <IconTooltip
      id={`info-${form.name}`}
      content={msg.p}
      title={msg.h}
      top={30}
      showStart
      showMedium
    /> : null}
    <div>
      {formFactory(elements.filter(e => !e.noBackground))}
    </div>
    <div>
      {formFactory(elements.filter(e => e.noBackground))}
    </div>
    {children}
  </form>
);

Now my problem is - when the name of the form changes it won't change the reducer in redux.

Eg I have a wizard and form named category in step 1 of wizard -> now i change to step 2 of the wizard and there is a form called amount. It will always stay category.

How to solve this issue?

Have you read the documentation on how to build wizard forms over here http://redux-form.com/6.6.3/examples/wizard/ ?

The documentation mentions that if you want to build a wizard, you need to connect each page of the wizard to the same form name, so you'd need to specify that explicitly.

Perhaps that solves your issue?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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