formsy-react: form is not resetting its value
my submit function
submit = (values) => {
return axios
.post('shops', values)
.then((res) => {
alert.success('Shop Created.'); // on success, its showing
this.refs.newShopForm.reset(); // but this is not setting forms value
})
.catch((err) => {
this.refs.newShopForm.updateInputsWithError(err.response.data); // on error, its showing errors
});
};
About this issue
- Original URL
- State: open
- Created 8 years ago
- Reactions: 1
- Comments: 17
I had the same problem but just with textarea fields. I have a formsy-react wrapper for my input components so I can use them with o without formsy-react. Calling reset was cleaning the values as expected but passing
undefinedas a value to the children component didn’t updated it so I end up passingvalue={this.getValue() || ''}and that solved the issueCannot for the life of me get the from to reset its inputs. Trying:
Tried passing value={this.state.something} and then calling this.setState({value: ‘’}) on submit. That didn’t work either.