-
-
Notifications
You must be signed in to change notification settings - Fork 65
fix loading logic #75
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
Conversation
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() |
There was a problem hiding this comment.
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) } |
There was a problem hiding this comment.
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
Thanks for the PR! Just to be clear, it only about calling |
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. |
oh yes good point |
If onClick() prop doesn't return promise, the button will stay in loading state forever;
additionally provide error object in handler