DEV Community

Max Angelo Perin (ᜋᜃᜐ)
Max Angelo 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…

Discussion (0)