简体   繁体   English

redux形式的动态名称不会更改减速器名称

[英]redux-form dynamic name does not change the reducer name

I'm using a redux-form like this: 我正在使用这样的redux形式:

 <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. 现在我的问题是-表单名称更改时,它不会更改redux中的reducer。

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. 例如,我在向导的第1步中有一个向导和名为category的表单->现在,我更改为向导的第2步,并且有一个名为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/ ? 您是否已在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? 也许可以解决您的问题?

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

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