react-images-upload
Advanced tools
Comparing version 1.2.6 to 1.2.7
@@ -29,2 +29,4 @@ 'use strict'; | ||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -53,3 +55,3 @@ | ||
_this.state = { | ||
pictures: props.defaultImage ? [props.defaultImage] : [], | ||
pictures: [].concat(_toConsumableArray(props.defaultImages)), | ||
files: [], | ||
@@ -81,4 +83,4 @@ notAcceptedFileType: [], | ||
value: function componentWillReceiveProps(nextProps) { | ||
if (nextProps.defaultImage) { | ||
this.setState({ pictures: [nextProps.defaultImage] }); | ||
if (nextProps.defaultImages !== this.props.defaultImages) { | ||
this.setState({ pictures: nextProps.defaultImages }); | ||
} | ||
@@ -385,3 +387,3 @@ } | ||
onChange: function onChange() {}, | ||
defaultImage: "" | ||
defaultImages: [] | ||
}; | ||
@@ -414,5 +416,5 @@ | ||
singleImage: _propTypes2.default.bool, | ||
defaultImage: _propTypes2.default.string | ||
defaultImages: _propTypes2.default.array | ||
}; | ||
exports.default = ReactImageUploadComponent; |
10
index.js
@@ -19,3 +19,3 @@ import React from 'react'; | ||
this.state = { | ||
pictures: props.defaultImage ? [props.defaultImage] : [], | ||
pictures: [...props.defaultImages], | ||
files: [], | ||
@@ -41,4 +41,4 @@ notAcceptedFileType: [], | ||
componentWillReceiveProps(nextProps){ | ||
if(nextProps.defaultImage){ | ||
this.setState({pictures: [nextProps.defaultImage]}); | ||
if(nextProps.defaultImages !== this.props.defaultImages){ | ||
this.setState({pictures: nextProps.defaultImages}); | ||
} | ||
@@ -269,3 +269,3 @@ } | ||
onChange: () => {}, | ||
defaultImage: "" | ||
defaultImages: [] | ||
}; | ||
@@ -298,5 +298,5 @@ | ||
singleImage: PropTypes.bool, | ||
defaultImage: PropTypes.string | ||
defaultImages: PropTypes.array | ||
}; | ||
export default ReactImageUploadComponent; |
{ | ||
"name": "react-images-upload", | ||
"version": "1.2.6", | ||
"version": "1.2.7", | ||
"private": false, | ||
@@ -5,0 +5,0 @@ "main": "compiled.js", |
29697
767