Go back and forth on react route without resetting Redux state?

Stack Overflow Asked by xaovnumwsercy on September 21, 2020

In my entry file, Ive 3 columns, I want first and last column to always be there, middle column displays different contents. I am rendering middle column as :

<Router className="middle">
      <Route exact path="/" component={World}></Route>
      <Route exact path="/countries/:countryId" component={Details} ></Route>

here World component has a list of cards, where for each card on click I want to show expanded details of it, at that "/countries/:countryId" url. So in World component (where I have list of cards) I have onClick on each card which does this:

loadDetails = (countryId: string) => {
        window.location.href = `/countries/${countryId}`;

Now I just want to replace middle world component with this details component but WITHOUT RELOADING, RESETTING REDUX. this details component also has back button to go back to "/" url and load World component.
by doing:

onBack={() => window.history.back()}

I might have to change this route and all, please help. Whats correct way to route in this case?

Route Structure:

    Post2 (onclick = load post details on "/countries/:countryid")

    (onclick = go back to "/")

Add your own answers!

Related Questions

Change null to 0 in response

1  Asked on December 3, 2021 by edwin-landsfield


Print complete SQL for all queries made by objection.js

2  Asked on December 3, 2021 by eugene-kim


Easiest way to convert a char* of hex to actual hex in C?

1  Asked on December 3, 2021 by purplespark


Xcode confused with IQAir Api Parsing

1  Asked on December 3, 2021 by unkowncoder


gRPC server cannot be built and throws error

0  Asked on December 3, 2021 by jibo_libin


How to correctly map huge json file to Java (pojo)?

1  Asked on December 3, 2021 by orkhan-hasanli


check all items in csv column except one [python pandas]

2  Asked on December 2, 2021 by blindside044


Unpivot a single into two rows – T-SQL

1  Asked on December 2, 2021 by error-1004


Ask a Question

Get help from others!

© 2022 All rights reserved. Sites we Love: PCI Database, MenuIva, UKBizDB, Menu Kuliner, Sharing RPP