DEV Community

Max Angelo Dapitilla Perin
Max Angelo Dapitilla Perin

Posted on

Answer: A component is changing an uncontrolled input of type text to be controlled error in ReactJS

The reason is, in state you defined:

this.state = { fields: {} }

fields as a blank object, so during the first rendering this.state.fields.name will be undefined, and the input field will get its value as:

value={undefined}

Because of that, the input field will become uncontrolled.

Once you enter…

Top comments (0)