I use react-router-dom to navigate between tabs in ReactJS project.
In the App component I have:
...
<Navbar collapseOnSelect id="topBar" bg="white" variant="light" sticky='top' expand="xl">
<Navbar.Brand href="/"></Navbar.Brand>
<Navbar.Toggle aria-controls="basic-navbar-nav"/>
<Navbar.Collapse>
<Nav justify className="textFontTabs textBig mr-auto" variant="tabs" defaultActiveKey="/"
activeKey={history.location.pathname}>
{tabs.map(tab =>
(<Nav.Link as={Link} key={tab.name} to={tab.pathname}>{tab.name}</Nav.Link>))
}
</Nav>
</Navbar.Collapse>
</Navbar>
</>
<Switch>
<Route exact path="/" render={() => <Home/>}/>
<Route path="/configurator" render={() =>
<Configurator contentHeight={contentHeight}/>}/>
</Switch>
...
My problem is that I have most of the data in the Configurator component stored in state hooks and when I change the tab, for example for Home, and come back to Configurator again, all the data I stored there is set to default. Is there a way to remember the data in Configurator? I've found out that I can use react-redux, but I think it's too small project to use it.