简体   繁体   English

将字段值与redux-form v6组合

[英]Combining field values with redux-form v6

I'm migrating part of an application from redux-form v5 to v6 ( alpha-10 ). 我正在将应用程序的一部分从redux-form v5迁移到v6alpha-10 )。 I need to display the combined values of some fields. 我需要显示某些字段的组合值。

In v5 , I would have something like: v5 ,我会有类似以下内容:

class MyForm extends Component {                            
  render() {                                                

    const { fields: { first, last }, handleSubmit } = this.props

    return (                                                
      <form onSubmit={handleSubmit}>                        

        <div>                                               
          <label>First name</label>
          <input type="text" {...first}/>
        </div>                                              

        <div>                                               
          <label>Last name</label>
          <input type="text" {...last}/>
        </div>

        <div>
          Welcome {first.value last.value.toUpperCase()}
        </div>

        <button type="submit">Submit</button>               
      </form>                                               
    )
  }
}

The last div of the form combines the values of my two first and last fields. 表格的最后一个div合并了我的两个firstlast字段的值。 How can I create such an element with v6 ? 如何使用v6创建这样的元素?

Just published an API for this exact thing. 刚刚发布了有关此确切内容的API。 Check out the Selecting Form Values example. 查看“ 选择表单值”示例。

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

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