React - clearing an input value after form submit

前端 未结 6 1248
粉色の甜心
粉色の甜心 2020-12-05 04:09

I\'m presented with a rather silly problem. I am in the process of creating my first React application and I have encountered a little issue, where I am not able to clear my

6条回答
  •  广开言路
    2020-12-05 04:40

    This is the value that i want to clear and create it in state 1st STEP

    state={
    TemplateCode:"",
    }
    

    craete submitHandler function for Button or what you want 3rd STEP

    submitHandler=()=>{
    this.clear();//this is function i made
    }
    

    This is clear function Final STEP

    clear = () =>{
      this.setState({
        TemplateCode: ""//simply you can clear Templatecode
      });
    }
    

    when click button Templatecode is clear 2nd STEP

提交回复
热议问题