Skip to content
Advertisement

404 page in REACT

I created the component NotFound and it works fine when I go to a page that doesn’t exist. But the same page it’s appearing in all my pages, not only the one that doesn’t exist. This is the component:

JavaScript

And this is how I used it in the main page:

JavaScript

As you can see I use <Route path="*" component={NotFound} /> to create the 404 pages, but that component is appearing in every existing page as well. How can I fix this?

Advertisement

Answer

Try this one:

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