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

What does useNavigate replace option do?

The docs say:

Either pass a To value (same type as <Link to>) with an optional
second { replace, state } arg or

without saying what it does. So does it replace the whole history stack or just the current route? I have no idea.

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 :

The replace options property is a REPLACE navigation action. It’s a redirect, replacing the current entry in the history stack versus PUSHing a new entry onto the top like a regular navigation.

navigate(path); // PUSH, navigate
navigate(path, { replace: true }); // REPLACE, redirect

useNavigate

The useNavigate hook returns a function that lets you navigate
programmatically, for example after a form is submitted. If using
replace: true, the navigation will replace the current entry in the
history stack instead of adding a new one
.

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