judelawlee
23 Aug '19
See this example and the Redux-form selecting values documentation. I haven’t worked directly with formValueSelector
, but I suspect you want something like this in your component:
import { formValueSelector, change } from 'redux-form'
componentWillUpdate(nextProps) {
if (nextProps.userCardNumber === '') {
this.props.dispatch(change('form', 'userName', ''));
this.props.dispatch(change('form', 'userMobile', ''));
}
}
and you will need to connect the form directly to the redux store as in the first example:
UserForm = stripesForm({
form: 'userForm',
...
})(UserForm);
const formSelector = formValueSelector('userForm');
export default connect(state => ({
userCardNumber: formSelector(state, 'userCardNumber'),
userName: formSelector(state, 'userName'),
userMobile: formSelector(state, 'userMobile'),
}))(UserForm);