Redux-Form update field value from external interaction
You can use react-redux’s mapDispatchToProps together with the change action creator in order to achieve what you want:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
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) |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.