Answers for "input type file reset react js"

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
0

How to reset ReactJS file input

<input onChange={this.onChange} onClick={e => (e.target.value = null)} type="file" />
Posted by: Guest on September-30-2021

Code answers related to "input type file reset react js"

Browse Popular Code Answers by Language