1.0.3 • Published 3 years ago

react-filepicker-hook v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

react-filepicker-hook

NPM JavaScript Style Guide

Install

npm install --save react-filepicker-hook

Usage

import React from 'react'

import { useFilePicker } from 'react-filepicker-hook'

const Example = () => {
  const { files, errors, FileInput, showFilePicker } = useFilePicker({
    minSize: 10000, // Size in Bytes
    maxSize: 10000000 // Size in Bytes
  })

  return (
    <>
      <button onClick={showFilePicker}>Show FileInput</button>
      {/* Include hidden input field and pass regular HTMLInput props */}
      <FileInput accept="image/*" multiple />
      <div>
        {errors.map(error => JSON.stringify(error))}
      </div>
      <div>
        {files.map(file => JSON.stringify(file.name))}
      </div>
    </>
  )
}

License

MIT © ryoid


This hook is created using create-react-hook.