Skip to content

Instantly share code, notes, and snippets.

@RodrigoTomeES
Last active June 10, 2020 10:54
Show Gist options
  • Save RodrigoTomeES/cdd07360eb03845a6a4445e069b805be to your computer and use it in GitHub Desktop.
Save RodrigoTomeES/cdd07360eb03845a6a4445e069b805be to your computer and use it in GitHub Desktop.
FileUpload.js usage example
import React from 'react'
const index = (props) => {
state = {
files: [
'nice.pdf',
'verycool.jpg',
'amazing.png',
'goodstuff.mp3',
'thankyou.doc'
]
}
handleDrop = (files) => {
let fileList = this.state.files
for (var i = 0; i < files.length; i++) {
if (!files[i].name) return
fileList.push(files[i].name)
}
this.setState({files: fileList})
}
return (
<FileUpload handleDrop={this.handleDrop}>
<div style={{height: 300, width: 250}}>
{this.state.files.map((file, i) =>
<div key={i}>{file}</div>
)}
</div>
</FileUpload>
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment