I have built a pretty standard form to update state and pass state through when the form is submitted; however, I am trying to add another button to reset some of the state values. The click event updates state fine, but it does not update the form inputs to reflect state. In this case, I am updating state as an object using the [name]:value method.
For example, here is my 'resetSome' function:
const resetSome = () => { setValues(...values, value3: '', value5: []) }
The function does update state on click, but the input components are not updated to reflect the new state. How do I make the components match state after resetSome?
https://stackoverflow.com/questions/65802947/updating-react-form-input-to-reflect-state-upon-reset January 20, 2021 at 12:07PM
没有评论:
发表评论