I'm new to react-router-dom, and I'm trying to create a tabs menu, with a different route for each tab. I'm trying to keep the tabs state persistent between tabs switching by keeping the hidden tabs mounted. How can I achieve this? React router remounts each component every time the route switches even when using the render prop as per the docs.
My contact component has an internal state, and when I navigate to another tab, it's unmounted so the state is lost
<Route path={`${path}`} exact render={() => <Home />} />
<Route path={`${path}/profile`} render={() => <Profile />} />
<Route path={`${path}/contact`} render={() => <Contact />} />
Here is a codesandbox for the example : https://codesandbox.io/s/gallant-lake-vhdby?file=/src/App.js