Yash Sharma
Yash Sharma

Reputation: 830

dynamic defaultValue on input type not working

I have a input type

<input defaultValue={this.getValue(labelName)} type="text" name={labelName} className="form-control" id={labelCateg+':'+labelName}  onChange={(e)=>{this.handleChange(e,labelName)}}/> 

If i specify the defaultValue="something" , it works
when i make it dynamic , on dev tools , it shows the value under value attribute but not on the view.

Upvotes: 0

Views: 123

Answers (1)

Yash Sharma
Yash Sharma

Reputation: 830

Changed it to controlled component . onChange changes the value at the source which indirectly changes the value on the dom on rerender

Upvotes: 1

Related Questions