Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR HTML

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>
  )
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #react #reset #file #input
ADD COMMENT
Topic
Name
8+6 =