Skip to content
Advertisement

How to show not found on base url

This is the code:

App

JavaScript

Base

JavaScript

NotFound

JavaScript

https://codesandbox.io/s/summer-sound-giti8c?file=/src/App.js

I want that when someone goes to the base url say https://giti8c.csb.app/ then NotFound component should be rendered.

Currently, only Base component renders on going to the base url.

Advertisement

Answer

I want that when someone goes to the base url say "https://giti8c.csb.app/" then NotFound component should be rendered.

Make an index route that also renders the NotFound component, to be matched and rendered only when the path exactly matches the parent route rendering the Outlet component.

See Index Routes

Example:

JavaScript
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement