Handling incorrect navigation requests
Graceful handling of incorrect navigation requests is mandatory in modern web development to ensure a smooth and user-friendly experience. By preventing users from encountering confusing error messages or broken links, you make your application feel professional and reliable. While we have already covered unauthorized navigation in Chapter 8, other error states might unexpectedly occur. How you handle broken links or mistyped URLs defines the quality of the user experience.
Let’s implement a global, safe redirection to a friendly error page when users face unexpected navigation exceptions.
Getting ready
Before implementing the safe redirection, you must have something to redirect to. If you have been following along with the entire book or just scaffolded your project, you already have a routable Error
component. Otherwise, you can get it from the Modules
directory in the GitHub repository.
How to do it…
Follow these...