How to reset ReactJS file input

后端 未结 10 1066
傲寒
傲寒 2020-12-29 00:55

I have file upload input:


And I handle upload t

10条回答
  •  醉话见心
    2020-12-29 01:55

    I do it by updating key inside my file input. This will force a re-render and previously selected file will go away.

    
    

    Changing the state inputKey will re-render the component. One way to change the inputKey will be to always set it to Date.now() on click of a button which is supposed to clear the field.

提交回复
热议问题