Created
December 3, 2017 16:40
-
-
Save MicroBenz/2784fbbf739f2f03b7dcff0365f8b601 to your computer and use it in GitHub Desktop.
Recompose
This file contains hidden or 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
import React from 'react'; | |
import { conenct } from 'react-redux'; | |
import { compose, lifecycle, branch, renderComponent, withProps } from 'recompose'; | |
import { loadCampers } from 'redux/campers/actions'; | |
const enhance = compose( | |
connect( | |
state => ({ | |
campers: state.campers.lists | |
}), | |
{ loadCampers } | |
), | |
branch(props => props.loading, renderComponent(Loader)), | |
withProps( | |
props => ({ | |
design: props.campers.filter(camper => camper.role === 'design'), | |
marketing: props.campers.filter(camper => camper.role === 'marketing'), | |
programming: props.campers.filter(camper => camper.role === 'programming'), | |
content: props.campers.filter(camper => camper.role === 'content'), | |
}) | |
), | |
lifecycle({ | |
componentDidMount() { | |
this.props.loadCampers(); | |
} | |
}) | |
); | |
const Campers = props => { | |
const { design, marketing, programming, content } = props; | |
return ( | |
<div> | |
<CamperTable lists={design} /> | |
<CamperTable lists={marketing} /> | |
<CamperTable lists={programming} /> | |
<CamperTable lists={content} /> | |
</div> | |
); | |
}; | |
export default enhance(Campers); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment