1/* Answer to: "react image upload" */
2
3/*
4 "react-images-upload" is a simple component for upload and
5 validate (client side) images with preview built with React.js.
6 This package use "react-flip-move [1]" for animate the file preview
7 images.
8
9 Download it here:
10 https://www.npmjs.com/package/react-images-upload
11
12 or if you need help or don't want to use packages,
13 you can watch this video:
14 https://www.youtube.com/watch?v=XeiOnkEI7XI
15
16 [1] Link to "react-flip-move", mentioned in the
17 "react-images-upload" summary:
18 https://github.com/joshwcomeau/react-flip-move
19*/
11
22
33
44
55
66
77
88
99
1010
1111
1212
1313
1414
1515
1616
1717
1818
1919
2020
2121
2222
2323
2424
2525
2626
2727
2828
2929
30import React from 'react';
31import ImageUploader from 'react-images-upload';
32
33class App extends React.Component {
34
35 constructor(props) {
36 super(props);
37 this.state = { pictures: [] };
38 this.onDrop = this.onDrop.bind(this);
39 }
40
41 onDrop(pictureFiles, pictureDataURLs) {
42 this.setState({
43 pictures: pictureFiles
44 });
45 }
46
47 render() {
48 return (
49 <ImageUploader
50 withIcon={true}
51 buttonText='Choose images'
52 onChange={this.onDrop}
53 imgExtension={['.jpg', '.gif', '.png', '.gif']}
54 maxFileSize={5242880}
55 />
56 );
57 }
58}