DEV Community

Asim Dahal
Asim Dahal

Posted on

2 1

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)

Collapse
 
256hz profile image
Abe Dolinger β€’

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

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

πŸ‘‹ Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay