Created
June 17, 2019 17:42
-
-
Save pfftdammitchris/09e5e54648933f7741a963646247fc60 to your computer and use it in GitHub Desktop.
This file contains 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