0.0.4 • Published 2 years ago

react-img-prev v0.0.4

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

react-img-prev

A react image picker with preview

It let you pick files from your computer and display only the first one.

Install :

npm install react-img-prev

How to use it :

import ReactImgPrev from "react-img-prev";

const Component = () => {

  const [files, setFiles] = useState({});

  return (
    <ReactImgPrev files={files.files} setFiles={setFiles} />
  )}

If you want to display your own placeholder in place of the default icon, you can pass it as a children.

import ReactImgPrev from "react-img-prev";

const Component = () => {

  const [files, setFiles] = useState({});

  return (
    <ReactImgPrev files={files.files} setFiles={setFiles} >
      <h1>Image</h1>
    </ReactImgPrev>
  )}

You can pass additional options.

Accepted props :

PropsTypeOptional ?Description
widthNumberyeswidth of the display preview
heightNumberyesheight of the display preview
classNamestringyesclass of the preview
acceptstringyestype accepted for input
maxstringyesmax number of file
filesFilenofiles selected
setFilesFunctionnoset selected files

License

Under the MIT license.