Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iagodahlem/fb2a8ad37093c670788b890f74654bce to your computer and use it in GitHub Desktop.
Save iagodahlem/fb2a8ad37093c670788b890f74654bce to your computer and use it in GitHub Desktop.
Scalable Frontend - The State Layer - Don't depend on the return of actions (wrong way)
// action
const loadProduct = (id) => (dispatch, _, container) => {
container.loadProduct({
onSuccess: (product) => dispatch(loadProductSuccess(product)),
onError: (error) => dispatch(loadProductError(error)),
})
}
// component
componentDidMount() {
const { productId, loadProduct, loadComments } = this.props
loadProduct(productId)
.then(() => loadComments(productId))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment