Clear an input field with Reactjs?

后端 未结 7 2003
囚心锁ツ
囚心锁ツ 2020-12-08 04:33

I am using a variable below.

var newInput = {
   title: this.inputTitle.value,
   entry: this.inputEntry.value    
};

This is used by my i

7条回答
  •  有刺的猬
    2020-12-08 04:36

    Declare value attribute for input tag (i.e value= {this.state.name}) and if you want to clear this input vale you have to use this.setState({name : ''})

    PFB working code for your reference :

    
    

提交回复
热议问题