Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

React Router V6 – page is not in history

I am using react router v6. When I am on detail page and i´ll press arrow in chrome go on prev page it doesnt go on prev page but prev prev page. I checked history by long press on arrow back and the page I need is not there. How can i add that page to the history?
On the detail page i navigate from main page with navigate(‘detailPage/key’).

Edit: In detail page i did something like this, but then is not detail page in history.

useEffect(() => {
    return () => navigate('/mainPage');
  }, [navigate]);`

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

For react-router-v6

import { Link } from 'react-router-dom';

This ‘/mainPage’ Page should be declared in App.js as a route.

  <Link to='/mainPage'><button>Go Main Page</button></Link>

You can check this link :https://github.com/remix-run/react-router/discussions/8465

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading