首页 文章

如何使用redux-form预填充输入字段的反应?

提问于
浏览
0

我在用什么:

  • redux-form@7.4.2

  • react-redux@5.0.7

  • reducex@4.0.0

  • react@16.4.1

我正在尝试使用上面提到的堆栈实现更新表单,我想用Redux数据预填充表单字段 . Redux表单已设置好并且正常工作 . 我不能预填充田地 .

我的问题是:redux如何处理Fields和initialState数据之间的连接,以便用正确的数据填充正确的输入字段?

我已经看到了下面的例子,但我还没弄清楚事情的运作方式 .

Redux Form Prepopulate from initial State

谢谢

1 回答

  • 0

    连接由 Field 组件中的 name 属性进行 . 所以:

    // your initialValues
    {
       name: 'Tom',
       surname: 'Rossi'
    }
    
    // your component
    <Field
       name: 'name'
       ...
    />
    
    <Field
       name: 'surname'
       ...
    />
    

相关问题