Redux-Form update field value from external interaction

核能气质少年 提交于 2019-11-30 12:23:49
gustavohenke

You can use react-redux's mapDispatchToProps together with the change action creator in order to achieve what you want:

import { Component } from "react";
import { connect } from "react-redux';
import { change } from "redux-form";

class ColorSelect extends Component {
  // ...other stuff in this class...

  renderColor (color) {
    const { selectColor } = this.props;
    return <li key={color}><a onClick={() => selectColor(color)}></a></li>;
  }
}

export default connect(null, {
  selectColor: color => change( "yourFormName", "yourFieldName", color )
})(ColorSelect)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!