Skip to content

Commit

Permalink
fix(Upload): Card progress under controled value. fix alibaba-fusion#…
Browse files Browse the repository at this point in the history
  • Loading branch information
bindoon authored and youluna committed Nov 20, 2020
1 parent b865019 commit edcea69
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion scripts/upload-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ http.createServer(function(req, res) {

form.parse(req, function(err, fields, files) {
if (err) {
res.send({ success: false, message: err });
res.end({ success: false, message: err });
return;
}

Expand Down
7 changes: 5 additions & 2 deletions src/upload/card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ class Card extends Base {
}

static getDerivedStateFromProps(nextProps, prevState) {
if ('value' in nextProps && nextProps.value !== prevState.value) {
const isUploading = prevState.uploaderRef && prevState.uploaderRef.isUploading();
if ('value' in nextProps && nextProps.value !== prevState.value && !isUploading) {
return {
value: !Array.isArray(nextProps.value) ? [] : [].concat(nextProps.value),
};
Expand All @@ -84,10 +85,12 @@ class Card extends Base {
return null;
}

onProgress = value => {
onProgress = (value, targetItem) => {
this.setState({
value,
});

this.props.onProgress(value, targetItem);
};

onChange = (value, file) => {
Expand Down

0 comments on commit edcea69

Please sign in to comment.