Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Last active June 16, 2019 17:56
Show Gist options
  • Save jsmanifest/0688a5fbf86c236e5a1d92b96c7eb26e to your computer and use it in GitHub Desktop.
Save jsmanifest/0688a5fbf86c236e5a1d92b96c7eb26e to your computer and use it in GitHub Desktop.
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