Last active
December 19, 2017 02:31
-
-
Save jide/94f6366bc612e09c5cc8ac651c85fd7f to your computer and use it in GitHub Desktop.
More complex optimized redux connectors.
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
import { connect } from 'react-redux'; | |
import { removeUser } from '../reducers/user'; | |
import Users from '../components/Users'; | |
const Container = connect( | |
(state, props) => ({ | |
users: state.users.all, | |
options: state.options, | |
isAdmin: state.currentUser[props.userId].isAdmin === true | |
}), | |
{ removeUser }, | |
null, | |
{ | |
areStatesEqual: (next, prev) => { | |
return ( | |
prev.users.all === next.users.all && | |
prev.options === next.options && | |
prev.currentUser === next.currentUser | |
); | |
} | |
} | |
)(Users); | |
export default Container; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment