Skip to content

Instantly share code, notes, and snippets.

@denisraslov
Last active September 11, 2017 20:34
Show Gist options
  • Save denisraslov/b5da5b87920bc46b383d278db2bcbcb8 to your computer and use it in GitHub Desktop.
Save denisraslov/b5da5b87920bc46b383d278db2bcbcb8 to your computer and use it in GitHub Desktop.
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