Skip to content

Instantly share code, notes, and snippets.

@e-l-i-s-e
Created November 18, 2018 20:14
Show Gist options
  • Select an option

  • Save e-l-i-s-e/b7f9522d799e6f6c6cf08e3c81ddb10d to your computer and use it in GitHub Desktop.

Select an option

Save e-l-i-s-e/b7f9522d799e6f6c6cf08e3c81ddb10d to your computer and use it in GitHub Desktop.
Medium article example
if (action instanceof Promise) {
this.setState({
[`${name}Status`]: {
isLoading: true
}
});
return action
.then(() => {
this.setState({
[`${name}Status`]: {
isLoading: false
},
});
})
.catch(error => {
this.setState({
[`${name}Status`]: {
isLoading: false,
error
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment