using location hook to properly update render so it highlights the correct button after it's pressed based on url
This commit is contained in:
parent
e95b654d7f
commit
a453147e9e
1 changed files with 6 additions and 5 deletions
|
|
@ -5,7 +5,7 @@ import classNames from "classnames";
|
||||||
import { useWidth } from "../hooks/useWidth";
|
import { useWidth } from "../hooks/useWidth";
|
||||||
import { makeStyles } from "@mui/styles";
|
import { makeStyles } from "@mui/styles";
|
||||||
import BindaptIcon from "../products/Bindapt/BindaptIcon";
|
import BindaptIcon from "../products/Bindapt/BindaptIcon";
|
||||||
import { Link } from "react-router-dom";
|
import { Link, useLocation } from "react-router-dom";
|
||||||
|
|
||||||
const drawerWidth = 230;
|
const drawerWidth = 230;
|
||||||
|
|
||||||
|
|
@ -78,6 +78,7 @@ export default function SideNavigator(props: Props) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const width = useWidth();
|
const width = useWidth();
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
const location = useLocation();
|
||||||
|
|
||||||
const getClasses = (page: string) => {
|
const getClasses = (page: string) => {
|
||||||
if (page === "/device") {
|
if (page === "/device") {
|
||||||
|
|
@ -105,8 +106,8 @@ export default function SideNavigator(props: Props) {
|
||||||
<Tooltip title="Devices" placement="right">
|
<Tooltip title="Devices" placement="right">
|
||||||
<ListItemButton
|
<ListItemButton
|
||||||
id="tour-dashboard"
|
id="tour-dashboard"
|
||||||
// component={Link}
|
component={Link}
|
||||||
// to="/devices"
|
to="/devices"
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
classes={getClasses("/device")}
|
classes={getClasses("/device")}
|
||||||
>
|
>
|
||||||
|
|
@ -122,12 +123,12 @@ export default function SideNavigator(props: Props) {
|
||||||
component={Link}
|
component={Link}
|
||||||
to="/teams"
|
to="/teams"
|
||||||
onClick={onClose}
|
onClick={onClose}
|
||||||
classes={getClasses("/device")}
|
classes={getClasses("/team")}
|
||||||
>
|
>
|
||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<People />
|
<People />
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
{open && <ListItemText primary="Devices" />}
|
{open && <ListItemText primary="Teams" />}
|
||||||
</ListItemButton>
|
</ListItemButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</List>
|
</List>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue