Quick background - I have a React Redux application created using CRA CLI. There are 2 pages or routes set up in my App.js using BrowserRouter and Route of react-router-dom. One is /products which displays all products. Second is /product-details which shows details of a product.
Problem 1 - When I come to the products page, the redux state has all the products information. When I manually navigate to the url /product-details, the redux state with all the product information is lost. Why is this happening?
Problem 2 - Other than manual navigation, How do I programmatically navigate from /products to /product-details page without losing the redux state?
I have tried using the BrowserHistory as suggested in other SO answers. But that does not seem to work for both my above problems.
<Router>
<div>
<Route path="/" exact component={Products} />
<Route path="/product-details" component={ProductDetails} />
</div>
</Router>
Expected
- When I manually navigate to product-details from the address bar, the state from /products page should be available
- Should be able to programmatically navigate to the /product-details page and the state available.