Skip to content

Instantly share code, notes, and snippets.

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