Skip to content

Instantly share code, notes, and snippets.

@Tiagoperes
Created May 22, 2019 17:39
Show Gist options
  • Select an option

  • Save Tiagoperes/6576899028059b668c92e250e191b706 to your computer and use it in GitHub Desktop.

Select an option

Save Tiagoperes/6576899028059b668c92e250e191b706 to your computer and use it in GitHub Desktop.
class Home extends PureComponent {
componentDidMount() {
const { loadCatalog } = this.props
loadCatalog()
}
render() {
const { catalog } = this.props
if (isPristine(catalog)) return null
if (isLoading(catalog)) return <Loading />
if (hasLoadError(catalog)) return <Error />
return <Content movies={catalog.data} />
}
}
const mapStateToProps = ({ catalog }) => ({ catalog })
const actions = { loadCatalog: resources.catalog.actions.load }
export default connect(mapStateToProps, actions)(Home)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment