DEV Community

Asim Dahal
Asim Dahal

Posted on


Cancel navigation on route change.

I have a component which requires confirmation before navigating to another component. There is a Prompt component in react router which enables to ask confirmation before navigating to another component but I can't find any similar solution in reach-router. Is there any way I can ask the user for confirmation before they navigate to another route and cancel the navigation if the user responds no?

Top comments (1)

256hz profile image
Abe Dolinger

You could show a modal from the navigation link, and have the buttons on the modal navigate or cancel.

Top Posts from the React Ecosystem

1. Changes In The Official React Documentation

The former React Docs Beta has been officially released as the updated React documentation at after years of hard work and refinement. Check out the brand new React Docs: What’s New in the Updated React Docs

2. CRA's Time is Over

React developer team has removed create-react-app (CRA) from official documentation rendering it no longer the default setup method for new projects. The bulky setup, slow, and outdated nature of CRA led to its removal: create-react-app is officially dead

3. How to Fetch Articles for Your Portfolio

Integrate the articles of your profile into your personal portfolio with either React, Vue, or Next.js by following these simple steps. It outlines how to include frontend to pull the information and correctly utilizes the API: How to Fetch Your Articles for Your Portfolio with React