# 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 version **1.0.20** (published 2020-10-20) · ISC license · 0 weekly downloads

## Install

```sh
npm install react-simple-dropzone
pnpm add react-simple-dropzone
yarn add react-simple-dropzone
bun add react-simple-dropzone
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.20 |
| Published | 2020-10-20 |
| First published | 2020-10-12 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 141.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | ace.blazer |
| Maintainers | ace.blazer |
| Keywords | react dropzone, dropzone, drag n drop, drag & drop, image upload, dropzone navigator, simple dropzone, simple image upload, base64, blob |

## Links

- npm: https://www.npmjs.com/package/react-simple-dropzone
- Repository: https://github.com/AceBlazer/react-simple-dropzone
- Homepage: https://github.com/AceBlazer/react-simple-dropzone#readme
- Issues: https://github.com/AceBlazer/react-simple-dropzone/issues
- npm.io page: https://npm.io/package/react-simple-dropzone

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^16.2.0
- [react-dom](https://npm.io/package/react-dom.md) ^16.2.0

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.0.20 (latest) — 2020-10-20
- 1.0.19 — 2020-10-19
- 1.0.18 — 2020-10-19
- 1.0.17 — 2020-10-19
- 1.0.16 — 2020-10-19
- 1.0.15 — 2020-10-19
- 1.0.14 — 2020-10-19
- 1.0.13 — 2020-10-15
- 1.0.12 — 2020-10-15
- 1.0.11 — 2020-10-15
- 1.0.10 — 2020-10-15
- 1.0.9 — 2020-10-15
- 1.0.8 — 2020-10-14
- 1.0.7 — 2020-10-14
- 1.0.6 — 2020-10-14
- … 6 more at https://npm.io/package/react-simple-dropzone/versions

## README

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:

```javascript
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:

```javascript
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:

```javascript
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
![](https://i.imgur.com/J0bJ8Uq.png)

> Drag and drop images from a website.

![](https://i.imgur.com/xtMtmSp.png)

> Image preview.

![](https://i.imgur.com/IIof3bC.png)

> Browse files with click.

### Properties (props)
| Prop  | Description  | Return | Default value |
| :------------ | :------------ | :------------ | :------------ |
| onSuccessB64 | Event called when the image drop is successful | base64 image format | undefined
| onSuccessBlob | Event called when the image drop is successful |  Blob image format | undefined
| onError | Event called when the image drop has failed | error message | undefined
| displayText | The text to display inside the dropzone | readOnly prop | "Drag & Drop images or click to upload" |
| preview | Enable/disable file preview | readOnly prop | true |
| validTypes | Valid file types that dropzone accepts | readOnly prop | ['image/jpeg', 'image/png', 'image/gif'] |
| accept | File types/signatures that dropzone accepts | readOnly prop | "image/*" |
| dragFromWeb | Enable/disable drag and drop from websites | readOnly prop | true |
| multiple | Enable/disable multiple file upload | readOnly prop | false |
| maxSize | Max size of file to drop in bytes | readOnly prop | 10e6 |
| clearOnInput | Enable/disable clear preview when input new files | readOnly prop | true |

### 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.

---
_Source: https://npm.io/package/react-simple-dropzone · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
