|
1 | 1 | import { ClassNameMap, createStyles, withStyles } from '@mui/styles';
|
2 |
| -import React from 'react'; |
| 2 | +import React, { useEffect } from 'react'; |
3 | 3 | import { connect } from 'react-redux';
|
4 | 4 | import Tabs from '@mui/material/Tabs';
|
5 | 5 | import { TabClasses } from '@mui/material/Tab/tabClasses';
|
6 | 6 | import Tab from '@mui/material/Tab';
|
7 |
| -import { Link } from 'react-router-dom'; |
| 7 | +import { Link, useLocation } from 'react-router-dom'; |
8 | 8 | import HelpContainer from 'components/help/HelpContainer';
|
9 | 9 | import history from 'modules/hist';
|
10 | 10 | import { CustomTheme } from '@mui/material/styles';
|
@@ -64,9 +64,13 @@ type TabWrapperProps = {
|
64 | 64 |
|
65 | 65 | function TabWrapper(props: TabWrapperProps) {
|
66 | 66 | const { classes, routes, snapshotAccessRequests } = props;
|
| 67 | + const [selectedTab, setSelectedTab] = React.useState<string>('datasets'); |
| 68 | + const location = useLocation(); |
67 | 69 |
|
68 |
| - const locationSplit = history.location.pathname.split('/'); |
69 |
| - const selectedTab = `/${locationSplit[1] || 'datasets'}`; |
| 70 | + useEffect(() => { |
| 71 | + const locationSplit = history.location.pathname.split('/'); |
| 72 | + setSelectedTab(`/${locationSplit[1] || 'datasets'}`); |
| 73 | + }, [location]); |
70 | 74 |
|
71 | 75 | const tabConfigs: Array<ITabConfig> = [
|
72 | 76 | { label: 'Datasets', path: '/datasets' },
|
|
0 commit comments