score:1

Accepted answer

check out this working example (i placed notes in each file):

https://codesandbox.io/s/modest-panini-hkzlv?file=/src/app.js

overview:

  • there are several ways to do this
  • my suggestion is to use the history npm and create a history.js file
  • you will also need to use router from react-router-dom
  • in your parent component, or in a context provider, you can store your state
  • in the parent component, use react-router-dom switch and route to place routes
  • depending on implementation, conditionally render show route for async state update
  • in your search component, place all your links using react-router-dom
  • on click links should also update app's state of your specific selection
  • this selection gets passed to the show route/component
  • in the show component attach an on click that uses history.goback and resets state

score:-1

this might help you:

this.props.history.goback();

it goes back to prev page


Related Query

More Query from same tag