react-dropzone 4.0.0 → 4.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.babelrc CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "presets": ["es2015", "react", "stage-0"],
2
+ "presets": ["env", "react", "stage-1"],
3
3
  "plugins": ["add-module-exports"]
4
4
  }
package/.eslintrc CHANGED
@@ -1,6 +1,10 @@
1
1
  {
2
2
  "extends": [
3
- "okonet"
3
+ "okonet",
4
+ "prettier"
5
+ ],
6
+ "plugins": [
7
+ "prettier"
4
8
  ],
5
9
  "rules": {
6
10
  // React
@@ -13,9 +17,7 @@
13
17
  ]
14
18
  }
15
19
  ],
16
-
17
- // a11y
18
- "jsx-a11y/no-static-element-interactions": 0,
20
+ "react/require-default-props": 0,
19
21
 
20
22
  // Import
21
23
  "import/no-extraneous-dependencies": [
package/.travis.yml CHANGED
@@ -3,9 +3,7 @@ cache: yarn
3
3
  notifications:
4
4
  email: false
5
5
  node_js:
6
- - '7'
7
- before_script:
8
- - npm prune
6
+ - '8'
9
7
  after_success:
10
8
  - bash <(curl -s https://codecov.io/bash)
11
9
  - npm run semantic-release
package/README.md CHANGED
@@ -1,14 +1,18 @@
1
- ![react-dropzone logo](https://raw.githubusercontent.com/okonet/react-dropzone/master/logo/logo.png)
1
+ ![react-dropzone logo](https://raw.githubusercontent.com/react-dropzone/react-dropzone/master/logo/logo.png)
2
2
 
3
3
  # react-dropzone
4
4
 
5
- [![Build Status](https://travis-ci.org/okonet/react-dropzone.svg?branch=master)](https://travis-ci.org/okonet/react-dropzone) [![npm version](https://badge.fury.io/js/react-dropzone.svg)](https://badge.fury.io/js/react-dropzone) [![codecov](https://codecov.io/gh/okonet/react-dropzone/branch/master/graph/badge.svg)](https://codecov.io/gh/okonet/react-dropzone) [![OpenCollective](https://opencollective.com/react-dropzone/backers/badge.svg)](#backers)
5
+ [![Build Status](https://travis-ci.org/react-dropzone/react-dropzone.svg?branch=master)](https://travis-ci.org/react-dropzone/react-dropzone) [![npm version](https://badge.fury.io/js/react-dropzone.svg)](https://badge.fury.io/js/react-dropzone) [![codecov](https://codecov.io/gh/react-dropzone/react-dropzone/branch/master/graph/badge.svg)](https://codecov.io/gh/react-dropzone/react-dropzone) [![OpenCollective](https://opencollective.com/react-dropzone/backers/badge.svg)](#backers)
6
6
  [![OpenCollective](https://opencollective.com/react-dropzone/sponsors/badge.svg)](#sponsors)
7
7
 
8
8
  Simple HTML5-compliant drag'n'drop zone for files built with React.js.
9
9
 
10
10
  Documentation and examples: https://react-dropzone.js.org
11
- Source code: https://github.com/okonet/react-dropzone/
11
+ Source code: https://github.com/react-dropzone/react-dropzone/
12
+
13
+ ---
14
+
15
+ **Looking for maintainers: https://github.com/react-dropzone/react-dropzone/issues/479**
12
16
 
13
17
  ---
14
18
 
@@ -19,18 +23,22 @@ Install it from npm and include it in your React build process (using [Webpack](
19
23
  ```bash
20
24
  npm install --save react-dropzone
21
25
  ```
26
+ or:
27
+ ```bash
28
+ yarn add react-dropzone
29
+ ```
22
30
 
23
31
  ## Usage
24
32
 
25
33
  Import `Dropzone` in your React component:
26
34
 
27
- ```javascript
35
+ ```javascript static
28
36
  import Dropzone from 'react-dropzone'
29
37
  ```
30
38
 
31
39
  and specify the `onDrop` method that accepts two arguments. The first argument represents the accepted files and the second argument the rejected files.
32
40
 
33
- ```javascript
41
+ ```javascript static
34
42
  function onDrop(acceptedFiles, rejectedFiles) {
35
43
  // do stuff with files...
36
44
  }
@@ -44,7 +52,7 @@ Using `react-dropzone` is similar to using a file form field, but instead of get
44
52
 
45
53
  Specifying the `onDrop` method, provides you with an array of [Files](https://developer.mozilla.org/en-US/docs/Web/API/File) which you can then send to a server. For example, with [SuperAgent](https://github.com/visionmedia/superagent) as a http/ajax library:
46
54
 
47
- ```javascript
55
+ ```javascript static
48
56
  onDrop: acceptedFiles => {
49
57
  const req = request.post('/upload');
50
58
  acceptedFiles.forEach(file => {
@@ -54,6 +62,25 @@ Specifying the `onDrop` method, provides you with an array of [Files](https://de
54
62
  }
55
63
  ```
56
64
 
65
+ **Warning**: On most recent browsers versions, the files given by `onDrop` won't have properties `path` or `fullPath`, see [this SO question](https://stackoverflow.com/a/23005925/2275818) and [this issue](https://github.com/react-dropzone/react-dropzone/issues/477).
66
+ If you want to access file content you have to use the [FileReader API](https://developer.mozilla.org/en-US/docs/Web/API/FileReader).
67
+
68
+ ```javascript static
69
+ onDrop: acceptedFiles => {
70
+ acceptedFiles.forEach(file => {
71
+ const reader = new FileReader();
72
+ reader.onload = () => {
73
+ const fileAsBinaryString = reader.result;
74
+ // do whatever you want with the file content
75
+ };
76
+ reader.onabort = () => console.log('file reading was aborted');
77
+ reader.onerror = () => console.log('file reading has failed');
78
+
79
+ reader.readAsBinaryString(file);
80
+ });
81
+ }
82
+ ```
83
+
57
84
  ## PropTypes
58
85
 
59
86
  See https://react-dropzone.netlify.com/#proptypes