Last active
September 11, 2017 20:34
-
-
Save denisraslov/b5da5b87920bc46b383d278db2bcbcb8 to your computer and use it in GitHub Desktop.
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 React from 'react'; | |
import { connect } from 'react-redux'; | |
import AdminContent from 'react/components/adminContent'; | |
import UserContent from 'react/components/userContent'; | |
class Page extends React.PureComponent { | |
// Use the state from the store | |
isUserAdmin() { | |
return this.props.userRoles.includes('ADMIN'); | |
} | |
render() { | |
if (this.isUserAdmin()) { | |
return <AdminContent />; | |
} else { | |
return <UserContent />; | |
} | |
} | |
} | |
function select(state) { | |
return { | |
userRoles: state.userRole | |
}; | |
} | |
export default connect(select)(Page); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment