Skip to content

Instantly share code, notes, and snippets.

@jsmanifest
Last active June 16, 2019 17:57
Show Gist options
  • Save jsmanifest/b548543e3582e4e902233738d24b7b32 to your computer and use it in GitHub Desktop.
Save jsmanifest/b548543e3582e4e902233738d24b7b32 to your computer and use it in GitHub Desktop.
import React from 'react'
import useApp from './useApp'
import FileUploader from './FileUploader'
import FileUploaderScreen from './FileUploaderScreen'
import './styles.css'
const App = ({ children }) => {
const inputRef = React.createRef()
const {
files,
pending,
next,
uploading,
uploaded,
status,
onSubmit,
onChange,
triggerInput,
} = useApp({ inputRef })
return (
<form className="form" onSubmit={onSubmit}>
<FileUploader
triggerInput={triggerInput}
inputRef={inputRef}
onChange={onChange}
>
<FileUploaderScreen />
</FileUploader>
<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