How to implement a custom component with two values in react-final-form

被刻印的时光 ゝ 提交于 2019-12-11 16:32:50

问题


I have a custom component which renders two values, mainOkved as a string and additionalOkveds as an array. In order to use it without react-final-form I simply add these values to the state and update them onSelect:

onSelectOkved(mainOkved, additionalOkveds) {
  this.setState({
    mainOkved: mainOkved,
    additionalOkveds: additionalOkveds
  });
}

The component itself looks like this:

<OkvedSelector mainOkved={this.state.mainOkved} additionalOkveds={this.state.additionalOkveds} onSelect={this.onSelectOkved} />

How can I implement this component with react-final-form? Should I use mutators or it can be done with a Field?

来源:https://stackoverflow.com/questions/57901348/how-to-implement-a-custom-component-with-two-values-in-react-final-form

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!