React Input Type not editable

后端 未结 3 1187
慢半拍i
慢半拍i 2020-12-14 18:12

I was adding dynamic values to the input file in react then I tried to edit that but it not at all editable.

var shop_profile_data = this.state.data.DETAILS         


        
3条回答
  •  無奈伤痛
    2020-12-14 18:17

    Since value is always rendered with the same value (shop_profile_data.NAME) nothing is able to change. By setting value property you are making input a Controlled Component.

    You need to add an onChange event and then set the shop_profile_data.NAME to a different value. Then the value of the input will change.

    If you only want to set the initial value of the input, use defaultValue property (docs). defaultValue will set the initial value, but then allow the value to be changed.

    For more read about Controlled vs Uncontrolled Components.

提交回复
热议问题