Skip to content

Conversation

xakep139
Copy link
Contributor

@xakep139 xakep139 commented Mar 9, 2017

If onClick() prop doesn't return promise, the button will stay in loading state forever;
additionally provide error object in handler

xakep139 and others added 3 commits March 9, 2017 09:48
If onClick() prop doesn't return promise, the button will stay in loading state forever
provide error in error handler
this.state.currentState !== STATE.LOADING) &&
this.state.currentState !== STATE.DISABLED
) {
this.loading()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

change state before calling handler

this.setState({currentState: STATE.NOTHING})
callback = callback || this.props.onError
if (typeof callback === 'function') { callback() }
if (typeof callback === 'function') { callback(err) }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

provide error object in callback

@mathieudutour
Copy link
Owner

Thanks for the PR!

Just to be clear, it only about calling loading before onClick right? I'm not sure how it's related to "If onClick() prop doesn't return promise, the button will stay in loading state forever;"

@xakep139
Copy link
Contributor Author

xakep139 commented Mar 9, 2017

If you make, for example, some synchronous checks in onClick() and decide to return button in state=STATE.NOTHING, it will suddenly start loading after that.

@mathieudutour
Copy link
Owner

oh yes good point

@mathieudutour mathieudutour merged commit a31cc54 into mathieudutour:master Mar 9, 2017
@xakep139 xakep139 deleted the patch-1 branch April 24, 2017 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants