Last active
March 29, 2019 15:17
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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