Created
November 8, 2017 10:50
-
-
Save YozhEzhi/74fd46b907e28604f9198ad96606d3fe to your computer and use it in GitHub Desktop.
Reselect example with using props.
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
| const makeGetPosts = () => createSelector( | |
| (state, props) => props.user, | |
| (state) => state.postsById, | |
| (state) => state.usersById, | |
| (state) => state.postListing, | |
| (userId, posts, users, listing) => listing | |
| .filter(id => posts[id].author === userId) | |
| .map(id => { | |
| const post = posts[id]; | |
| return {...post, user: users[post.author]} | |
| }), | |
| ); | |
| const mapState = () => { | |
| const getPosts = makeGetPosts(); | |
| return (state, ownProps) => { | |
| return {posts: getPosts(state, ownProps)}; | |
| }; | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment