Skip to content

Instantly share code, notes, and snippets.

@pfftdammitchris
Created June 17, 2019 17:42
Show Gist options
  • Save pfftdammitchris/09e5e54648933f7741a963646247fc60 to your computer and use it in GitHub Desktop.
Save pfftdammitchris/09e5e54648933f7741a963646247fc60 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