Skip to content
Advertisement

My input didn’t update value when I update state

I made two components, one is sign in component and one is form input.

I pass props to form input to render some input form.

And I also had a state to save the value of this inputs (two way binding).

Rendering is fine till now.

The problem when I submit form and set state to initial, i saw the state change in console log but my inputs didn’t display that, they still had displayed the last values that I submited.

Thanks for your help

This is my SignIn component:

JavaScript

And this is my FormInput component:

JavaScript

Advertisement

Answer

You missed to pass the value to input in your FormInput component that’s why it is not getting cleared.

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement