Last active
June 16, 2019 17:56
-
-
Save jsmanifest/0688a5fbf86c236e5a1d92b96c7eb26e 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 useApp from './useApp' | |
import './styles.css' | |
const Input = (props) => ( | |
<input | |
type="file" | |
accept="image/*" | |
name="img-loader-input" | |
multiple | |
{...props} | |
/> | |
) | |
const App = ({ children }) => { | |
const { | |
files, | |
pending, | |
next, | |
uploading, | |
uploaded, | |
status, | |
onSubmit, | |
onChange, | |
} = useApp() | |
return ( | |
<form className="form" onSubmit={onSubmit}> | |
<div> | |
<Input onChange={onChange} /> | |
<button type="submit">Submit</button> | |
</div> | |
<div> | |
{files.map(({ file, src, id }, index) => ( | |
<div key={`file-row${index}`}> | |
<img src={src} alt="" /> | |
<div>{file.name}</div> | |
</div> | |
))} | |
</div> | |
</form> | |
) | |
} | |
export default App |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment