Answers for "how to clear the file input field after submit react"

2

clear input file html react

e.target.value = null;
Posted by: Guest on March-08-2020
0

react reset file input

functionThatResetsTheFileInput() {
  let randomString = Math.random().toString(36);

  this.setState({
    theInputKey: randomString
  });
}

render() {
  return(
    <div>
      <input type="file"
             key={this.state.theInputKey || '' } />
      <button onClick={this.functionThatResetsTheFileInput()} />
    </div>
  )
}
Posted by: Guest on March-10-2021

Code answers related to "how to clear the file input field after submit react"

Browse Popular Code Answers by Language