react-filepicker-hook
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

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.

Readme

Keywords

none

Package Sidebar

Install

npm i react-filepicker-hook

Weekly Downloads

75

Version

1.0.3

License

MIT

Unpacked Size

636 kB

Total Files

22

Last publish

Collaborators

  • ryoid