Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expose reset function #46

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ React.render(<Upload />, container);
|onProgress | function || progress callback, only for modern browsers|
|beforeUpload| function |null| before upload check, return false or a rejected Promise will stop upload, only for modern browsers|
|withCredentials | boolean | false | ajax upload with cookie send |
|toggleToReset | boolean | - | toggle it when you want to reset the upload |

#### onError arguments

Expand Down
7 changes: 7 additions & 0 deletions src/AjaxUploader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const AjaxUploader = React.createClass({
headers: PropTypes.object,
beforeUpload: PropTypes.func,
withCredentials: PropTypes.bool,
toggleToReset: PropTypes.bool,
},

getInitialState() {
Expand All @@ -25,6 +26,12 @@ const AjaxUploader = React.createClass({
};
},

componentWillReceiveProps(nextProps) {
if (this.props.toggleToReset !== nextProps.toggleToReset) {
this._reset();
}
},

onChange(e) {
if (this.state.disabled) {
return;
Expand Down
1 change: 1 addition & 0 deletions src/Upload.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const Upload = React.createClass({
onReady: PropTypes.func,
withCredentials: PropTypes.bool,
supportServerRender: PropTypes.bool,
toggleToReset: PropTypes.bool,
},

getDefaultProps() {
Expand Down