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

Get data from DataGrid if DataGridCheckBoxColumn is checked

0  Asked on November 4, 2021 by user12711263


The value of local variable isn’t used

1  Asked on November 4, 2021 by greenycodeskii


clickhouse : information_schema.KEY_COLUMN_USAGE

1  Asked on November 4, 2021 by sravya-jasthi


WPF prevent combobox selection change under condition

1  Asked on March 8, 2021 by hasan-h


How to listen to Boot Complete broadcast in Oneplus?

1  Asked on March 8, 2021 by saarang-tiwari


Indirection requires pointer operand error

1  Asked on March 8, 2021 by mr-needhelp


Point Cloud Segmentation

1  Asked on March 7, 2021 by aldi-lin


Angular HTTP get request is not working in ngOnInit

1  Asked on March 6, 2021 by iamgrooot


CheckedChanged not triggering

0  Asked on March 6, 2021


flutter splash screen is blurry on physical device

1  Asked on March 5, 2021 by mohamed-mostapha


Nginx syslog post request

1  Asked on March 5, 2021 by andreas-hunter


Cloning Objects in Google Optimize

0  Asked on March 4, 2021 by jpfotoz


Specialize how std::vector grows

3  Asked on March 3, 2021 by gary-allen


Ask a Question

Get help from others!

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