use constructor bound methods for nav group

This commit is contained in:
Jake McDermott 2019-01-03 11:53:59 -05:00
parent 24208197e8
commit 5948ecce16
No known key found for this signature in database
GPG Key ID: 9A6F084352C3A0B7

View File

@ -14,15 +14,20 @@ class NavExpandableGroup extends Component {
// Extract a list of paths from the route params and store them for later. This creates
// an array of url paths associated with any NavItem component rendered by this component.
this.navItemPaths = routes.map(({ path }) => path);
this.isActiveGroup = this.isActiveGroup.bind(this);
this.isActivePath = this.isActivePath.bind(this);
}
isActiveGroup = () => this.navItemPaths.some(this.isActivePath);
isActiveGroup () {
return this.navItemPaths.some(this.isActivePath);
}
isActivePath = (path) => {
isActivePath (path) {
const { history } = this.props;
return history.location.pathname.startsWith(path);
};
}
render () {
const { groupId, groupTitle, routes } = this.props;