Skip to content

Commit d69aee8

Browse files
committed
Pass location to SidebarLink through Sidebar component
1 parent 294e811 commit d69aee8

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

src/components/Sidebar/SidebarContainer.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import { withTheme } from '@material-ui/core/styles';
22
import { compose, withState, withHandlers, lifecycle } from 'recompose';
33
import { connect } from 'react-redux';
4+
import { withRouter } from "react-router-dom";
45

56
import { toggleSidebar } from '../Layout/LayoutState';
67

78
import SidebarView from './SidebarView';
89

910
export default compose(
11+
withRouter,
1012
withTheme(),
1113
connect(
1214
state => ({

src/components/Sidebar/SidebarView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const structure = [
4848
{ id: 14, label: 'Background', link: '', icon: <Dot size="large" color="secondary" /> },
4949
];
5050

51-
const SidebarView = ({ classes, theme, toggleSidebar, isSidebarOpened, isPermanent }) => {
51+
const SidebarView = ({ classes, theme, toggleSidebar, isSidebarOpened, isPermanent, location }) => {
5252
return (
5353
<Drawer
5454
variant={isPermanent ? 'permanent' : 'temporary'}
@@ -73,7 +73,7 @@ const SidebarView = ({ classes, theme, toggleSidebar, isSidebarOpened, isPermane
7373
</IconButton>
7474
</div>
7575
<List className={classes.sidebarList}>
76-
{structure.map(link => <SidebarLink key={link.id} isSidebarOpened={isSidebarOpened} {...link} />)}
76+
{structure.map(link => <SidebarLink key={link.id} location={location} isSidebarOpened={isSidebarOpened} {...link} />)}
7777
</List>
7878
</Drawer>
7979
);

src/components/Sidebar/components/SidebarLink/SidebarLinkView.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import {
1212
import { Link } from "react-router-dom";
1313
import classnames from "classnames";
1414
import { Inbox as InboxIcon } from "@material-ui/icons";
15-
import { withRouter } from "react-router-dom";
1615

1716
import Dot from "../Dot";
1817

@@ -29,6 +28,7 @@ const SidebarLink = ({
2928
isOpen,
3029
toggleCollapse
3130
}) => {
31+
3232
const isLinkActive =
3333
link &&
3434
(location.pathname === link || location.pathname.indexOf(link) !== -1);
@@ -192,4 +192,4 @@ const styles = theme => ({
192192
}
193193
});
194194

195-
export default withRouter(withStyles(styles, { withTheme: true })(SidebarLink));
195+
export default withStyles(styles, { withTheme: true })(SidebarLink);

0 commit comments

Comments
 (0)