I am using Material Ui tabs for routing in my react app. I can set the default url (so that a '/' url will redirect to the '/firsttab' route, but this will not make the 'First' tab appear as active even if the route is correct. How can I accomplish this? Thank you!
const routes = ["/firsttab", "/secondtab"];
function MainNavigation() {
return (
<div >
<IonToolbar >
<BrowserRouter >
<Route
path="/"
render={(history) => (
<AppBar>
<Tabs
className='mat-tab-nav-bar'
TabIndicatorProps={{style: {background:'primary'}}}
indicatorColor="primary"
color="primary"
variant="scrollable"
scrollButtons="auto"
aria-label="scrollable auto tabs"
value={history.location.pathname !== "/" ? history.location.pathname : false}
>
<Tab className="mat-tab"
label="First"
value={routes[1]}
component={Link}
to={routes[1]}
></Tab>
<Tab className="mat-tab "
label="Second"
value={routes[0]}
component={Link}
to={routes[0]}
></Tab>
</Tabs>
</AppBar>
)}
></Route>
<Switch >
<Route path="/scutes" component={Second}></Route>
<Route path="/gateways" component={First}></Route>
<Redirect exact from="/" to="/firsttab" /> <- this is the initial route redirect
</Switch>
</BrowserRouter>
</IonToolbar>
</div>
);
}
export default MainNavigation;