Created
June 22, 2017 04:27
-
-
Save abiodun0/a62cecad97c678e0f2a6140e194f3a43 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 User from './User'; | |
import { connect } from 'react-redux'; | |
import { fetchUsers } from '../actions/index'; | |
import { lifecycle, compose } from 'recompose'; | |
const enhance = compose( | |
lifecycle({ | |
componentDidMount() { | |
this.props.fetchUsers(); | |
} | |
}) | |
) | |
export const UserList = ({ users }) => ( | |
<ul className="userlist"> | |
{users.map((user, i) => <User key={i} {...user} />)} | |
</ul> | |
); | |
const mapStateToProps = ({ users }) => ({ users }); | |
export default connect(mapStateToProps, {fetchUsers})(enhance(UserList)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment