close

[Solved] A component is changing an uncontrolled input of type text to be controlled error in ReactJS

Hello Guys, How are you all? Hope You all Are Fine. Today I get the following error A component is changing an uncontrolled input of type text to be controlled error in ReactJS in javascript. So Here I am Explain to you all the possible solutions here.

Without wasting your time, Let’s start This Article to Solve This Error.

How A component is changing an uncontrolled input of type text to be controlled error in ReactJS Error Occurs?

Today I get the following error A component is changing an uncontrolled input of type text to be controlled error in ReactJS in javascript.

How To Solve A component is changing an uncontrolled input of type text to be controlled error in ReactJS Error ?

  1. How To Solve A component is changing an uncontrolled input of type text to be controlled error in ReactJS Error ?

    To Solve A component is changing an uncontrolled input of type text to be controlled error in ReactJS Error Put empty value if the value does not exist or null.
    value={ this.state.value || "" }

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

    To Solve A component is changing an uncontrolled input of type text to be controlled error in ReactJS Error Put empty value if the value does not exist or null.
    value={ this.state.value || "" }

Solution 1

Changing value to defaultValue will resolve it.

Note:

defaultValue is only for the initial load. If you want to initialize the input then you should use defaultValue, but if you want to use state to change the value then you need to use value. Read this for more.

I used value={this.state.input ||""} in input to get rid of that warning.

Solution 2

Put empty value if the value does not exist or null.

value={ this.state.value || "" }

Summery

It’s all About this issue. Hope all solution helped you a lot. Comment below Your thoughts and your queries. Also, Comment below which solution worked for you? Thank You.

Also Read

Leave a Comment