DEV Community

Discussion on: Simplify controlled components with React hooks

Collapse
 
chandra profile image
Chandra Prakash Tiwari

This is a good approach, but this didn't worked for me.
still showing

index.js:1 Warning: A component is changing an uncontrolled input of type number to be controlled. Input elements should not switch from uncontrolled to controlled (or vice versa). Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://fb.me/react-controlled-components
Collapse
 
chandra profile image
Chandra Prakash Tiwari

I think you are not using the value of the state object as the value of input..
this is not the controlled input here.

<input type="text" name="username" onChange={handleInputChange} />