# react-easy-upload

> Simplifying upload for react

Latest version **0.0.4** (published 2018-10-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-easy-upload
pnpm add react-easy-upload
yarn add react-easy-upload
bun add react-easy-upload
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.4 |
| Published | 2018-10-11 |
| First published | 2018-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Marcos Andrei Ivanechtchuk |
| Maintainers | ivmarcos |
| Keywords | upload, easy, simple, react |

## Links

- npm: https://www.npmjs.com/package/react-easy-upload
- Repository: https://github.com/ivmarcos/react-easy-upload
- Homepage: https://github.com/ivmarcos/react-easy-upload#readme
- Issues: https://github.com/ivmarcos/react-easy-upload/issues
- npm.io page: https://npm.io/package/react-easy-upload

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.4 (latest) — 2018-10-11
- 0.0.3 — 2018-10-10
- 0.0.2 — 2018-10-10
- 0.0.1 — 2018-10-10

## README

# React Easy Upload

Simplifying upload for React. No dependencies.

## Install

```
$ npm install react-easy-upload
```

## Examples

* Basic - https://codesandbox.io/s/rr2ym0p49q
* Image - https://codesandbox.io/s/94jy5n6zjo
* Size validation - https://codesandbox.io/s/0qmok52z5n

## Usage

**Basic**

```jsx

import Upload from 'react-easy-upload'

...

<Upload onUpload={files => console.log('files uploaded', files)}>
    {({ files, requestUpload }) => (
        <div style={{width: 500, height: 500, background: 'red'}} onClick={requestUpload}>
            {files.length ? files[0].name : 'no file selected'}
        </div>
    )}
</Upload>
```

**All options**

```jsx
import Upload from 'react-easy-upload'

...

<Upload onUpload={files => console.log('files uploaded', files)} maxSize={1024*1024} multiple required accept="image/*">
    {({ files, requestUpload }) => (
        <div style={{width: 500, height: 500, background: 'red'}} onClick={requestUpload}>
            {files.length ? files[0].name : 'no file selected'}
        </div>
    )}
</Upload>
```

**Using withUpload**
```jsx
import { withUpload } from 'react-easy-upload'

...
const Box = ({requestUpload, files, valid}) => (
    <div style={{width: 500, height: 500, background: valid ? 'green' : 'red'}} onClick={requestUpload}>{files.length ? files[0].name : 'no file selected'}</div>
);
const BoxUpload = withUpload(Box);

<BoxUpload onUpload={files => console.log('files', files)} maxSize={1024*1024}/>
```

## Props

|Prop name  |Type                                            |Default    |Description
|-----------|------------------------------------------------|-----------|---------------------------------------
|onUpload   |`function(files: File[], event: SyntheticEvent)`|           | Callback when user uploads
|maxSize    |`number`                                        |           | Max size in bytes for each file on upload
|accept     |`string`                                        |           | Which files to accept. [See more](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#Limiting_accepted_file_types)
|multiple   |`boolean`                                       |   false   | True to accept multiple files
|required   |`boolean`                                       |   false   | True to define as required

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