Created
June 14, 2019 23:19
-
-
Save zackshapiro/3f154d73c317a62751d2ed23cfae6422 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import useFileHandlers from './useFileHandlers' | |
import './App.css' | |
const Input = (props) => ( | |
<input | |
type='file' | |
accept='image/*' | |
name='img-loader-input' | |
multiple | |
{...props} | |
/> | |
) | |
const App = () => { | |
const { | |
files, | |
pending, | |
next, | |
uploading, | |
uploaded, | |
status, | |
onSubmit, | |
onChange, | |
} = useFileHandlers() | |
return ( | |
<div className='container'> | |
<form className='form' onSubmit={onSubmit}> | |
<div> | |
<Input onChange={onChange} /> | |
<button type='submit'>Submit</button> | |
</div> | |
<div> | |
{files.map(({ file, src, id }, index) => ( | |
<div key={`thumb${index}`} className='thumbnail-wrapper'> | |
<img className='thumbnail' src={src} alt='' /> | |
<div className='thumbnail-caption'>{file.name}</div> | |
</div> | |
))} | |
</div> | |
</form> | |
</div> | |
) | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment