Reputation: 119
My "404 not found page" with React router is not working. This is how I use Router(v6):
<BrowserRouter>
<Routes>
<Route path='*' element={<Notfound/>} />
<Route path="/" element={<Homepage/>} />
<Route path="/home" element={<Homepage/>} />
<Route path="/about" element={<Aboutpage/>} />
<Route path="/picture" element={<Picturepage/>} />
<Route path="/projects" element={<Projectpage/>} />
</Routes>
</BrowserRouter>
The "Not found" element is the page I'm looking for, but it seems it doesn't work for me. In the Notfound.js I wrote like this:
import React from 'react'
const Notfound = () => {
return (
<div className='Notfound'>404 Notfound</div>
)
}
export default Notfound
I imported the page, but I can't fix this. Thanks for all your help
Upvotes: 2
Views: 1823
Reputation: 251
Try this for your NotFound Path
<Route path = '/*' element = {<NotFound />}>
Upvotes: 0
Reputation: 148
you need to define your Notfound page path like below 👇
<Route path='/*' element={<Notfound/>} />
Upvotes: 1