New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-simple-dropzone

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-simple-dropzone

simple, easy to use dropzone for react with a small, light bundle size of 130kb, it contains only the necessary functionnalities written with vanilla javascript it includes also drag and drop images from browser (within the same website or another website

latest
Source
npmnpm
Version
1.0.20
Version published
Maintainers
1
Created
Source

React-simple-dropzone

Description

Simple, easy to use dropzone with preview for react. With a small, light bundle size of 130kb, it contains only the necessary functionnalities written with vanilla javascript. It includes also drag and drop images from browser (within the same website or another website).

Examples

  • Use the dropzone and retrieve uploaded image in blob format:
import React, {useState} from 'react';
import Dropzone from 'react-simple-dropzone/dist';

function App() {
  const [image, setImage] = useState(null);
  return (
    <Dropzone onSuccessBlob={ (img) => setImage(img) } />
  );
}
export default App;
  • Use the dropzone and retrieve uploaded image in base64 format:
import React, {useState} from 'react';
import Dropzone from 'react-simple-dropzone/dist';

function App() {
  const [image, setImage] = useState(null);
  return (
    <Dropzone onSuccessB64={ (img) => setImage(img) } />
  );
}
export default App;
  • Multiple images dropzone with preview with a custom display text and error handler:
import React, {useState} from 'react';
import Dropzone from 'react-simple-dropzone/dist';

function App() {
  const [image, setImage] = useState(null);
  const [error, setError] = useState(null);
  return (
    <Dropzone multiple="true" preview="true" displayText="Choisissez un fichier ou faites glisser un fichier ici" onError={ (err) => setError(err) } />
  );
}
export default App;

Screenshots

Drag and drop images from a website.

Image preview.

Browse files with click.

Properties (props)

PropDescriptionReturnDefault value
onSuccessB64Event called when the image drop is successfulbase64 image formatundefined
onSuccessBlobEvent called when the image drop is successfulBlob image formatundefined
onErrorEvent called when the image drop has failederror messageundefined
displayTextThe text to display inside the dropzonereadOnly prop"Drag & Drop images or click to upload"
previewEnable/disable file previewreadOnly proptrue
validTypesValid file types that dropzone acceptsreadOnly prop['image/jpeg', 'image/png', 'image/gif']
acceptFile types/signatures that dropzone acceptsreadOnly prop"image/*"
dragFromWebEnable/disable drag and drop from websitesreadOnly proptrue
multipleEnable/disable multiple file uploadreadOnly propfalse
maxSizeMax size of file to drop in bytesreadOnly prop10e6
clearOnInputEnable/disable clear preview when input new filesreadOnly proptrue

Changelog

  • Earlier versions: Not stable.
  • Version 1.0.19: Most stable basic version with onSuccessB64 and onSuccessBlob props.
  • Version 1.0.20: Will have (onError, displayText, validTypes, accept, dragFromWeb, clearOnInput, preview, maxSize and multiple) props available.

Keywords

react dropzone

FAQs

Package last updated on 20 Oct 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts