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
CodePudding user response:
Try using <Route path='/*' element={<Notfound/>} >
CodePudding user response:
you need to define your Notfound page path like below