Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Created June 16, 2019 17:48
Show Gist options
  • Save jsmanifest/fadbcc89efc36af4b9e7d9e6583fa618 to your computer and use it in GitHub Desktop.
Save jsmanifest/fadbcc89efc36af4b9e7d9e6583fa618 to your computer and use it in GitHub Desktop.
const onChange = (e) => {
if (e.target.files.length) {
const arrFiles = Array.from(e.target.files)
const files = arrFiles.map((file, index) => {
const src = window.URL.createObjectURL(file)
return { file, id: index, src }
})
dispatch({ type: 'load', files })
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment