Prevent Navigation with the React Router Prompt Component

InstructorJason Brown

Share this video with your friends

Send Tweet

In this lesson we'll show how to setup the Prompt component from React Router. We'll prompt with a static message, as well as a dynamic method with the message as a function. Finally we'll show that you can return true from the message as a function to dynamically allow navigation.

Perfect Developer
~ 5 years ago

Can we have a custom prompt ? Or can we detect when the user wants only to change route without using <Promp /> component ?