3

how I can reset my component Dropzone whit state. My state is

    this.state = {
      files : [],
    }

My component is

<Dropzone 
getUploadParams={this.getUploadParams}
onChangeStatus={this.handleChangeStatus} 
onSubmit={this.handleSubmitUploadFile}
initialFiles={this.state.files || ''}
accept=".XLS,.XLSX"
inputContent={(files, extra) => (extra.reject ? 'Archivos' : 'Arrastrar archivo')}
canRestart={true}
canCancel={true}
canRemove={true}
multiple={false}
maxFiles={1}
maxSizeBytes={(1024 * 1024) * 6}
/>

But I need to reset it from a button, using the event onClick

My botton is

<Button size="sm" color="danger" onClick={this.resetFormImport}>
  <i className="fa fa-ban"></i> 
   Reset
</Button>

I try to update my state to refresh the component but it doesn't give any results.

resetFormImport() {
    this.setState({
      files : [],
    })
  }

Some solution??

how I can reset the component??

Andres Condo
  • 71
  • 1
  • 4

1 Answers1

1

You need to create your own state for acceptedFiles. This should help

https://github.com/react-dropzone/react-dropzone/issues/805