-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Description
Describe the bug
I have defined defaultComponent that should be rendered when exact route match is not found:
const router = createReactRouter({
routeConfig,
defaultComponent: NotFound,
});Now if I go to /seppo, which is a valid path if my application (route and component is defined), everything works fine.
However, if I go to /seppo/invalid, I would except NotFound to be rendered since seppo/invalid is not defined anywhere. The end result is, however, that a component for /seppo is rendered. It seems that React Router does not care about exact matches, but matches all invalid paths under the parent url to the parent url. I.e. /seppo path works like/seppo/* even if there is no wildchard in /seppo.
Is this the correct behaviour by design?
If it is, how do I change it so that only exact matches are rendered to their respective components and everything else fallbacks to defaultComponent?
In the end, I want to create a 404 page that is rendered when the path is invalid. I did not find an example of this anywhere.
Your Example Website or App
Steps to Reproduce the Bug or Issue
Expected behavior
defaultComponent should be rendered when exact match is not found.
Screenshots or Videos
No response
Platform
macOS Monterey
Additional context
No response