Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

clear input file html react

e.target.value = null;
Comment

How to reset ReactJS file input

<input onChange={this.onChange} onClick={e => (e.target.value = null)} type="file" />
Comment

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>
  )
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord.js random output 
Javascript :: react router dom v6 
Javascript :: empty check on django json field 
Javascript :: sum index of an array javascript 
Javascript :: carousel react 
Javascript :: leaflet remove layergroup 
Javascript :: currentTime(); javascript 
Javascript :: lodash count duplicates in array 
Javascript :: async await in javascript 
Javascript :: js local file read to blob variable 
Javascript :: how to use require() and import in the same time 
Javascript :: command to start a new react app using vite 
Javascript :: hello world react 
Javascript :: onchange on multiple ids jquery 
Javascript :: post to /wp-json/wp/v2/media 
Javascript :: npm get package.json version 
Javascript :: js check collision 
Javascript :: regex 
Javascript :: find max number in java 
Javascript :: array destructuring in react 
Javascript :: jquery get fail 
Javascript :: import tippy react 
Javascript :: jquery remove elemtns 
Javascript :: useEffect in nextjs 
Javascript :: javascript set value html element by class 
Javascript :: javascript screenshot 
Javascript :: joi regex validate 
Javascript :: javascript break and continue 
Javascript :: get main tr from td jquery 
Javascript :: CSRF token in js 
ADD CONTENT
Topic
Content
Source link
Name
4+1 =