In reduction forms, you can call the initialize()
following values โโwith an object:
class MyForm extends Component {
componentWillMount () {
this.props.initialize({ name: 'your name' });
}
componentWillReceiveProps (nextProps) {
if () {
this.props.destroy();
this.props.initialize({โฆ});
}
}
render () {
return (
<form>
<Field name="name" component="โฆ" />
</form>
);
}
}
export default reduxForm({})(MyForm);
This way you can update the default values โโover and over, but if you just need to do it the first time, you can:
export default reduxForm({values: {โฆ}})(MyForm);
source
share