score:2

Accepted answer
import { 
  BrowserRouter,
  Routes,
  Route,
  Navigate
} from 'react-router-dom';

...

<Routes>
  <Route path='/' element={<Homepage />} />
  <Route path='/contact' element={<Contact />} />
  <Route path='/contactsuccess' element={<Success />} />
  <Route path='/contacterr' element={<Error />} />
  <Route path='/bookpage' element={<Bookpage />} />
  <Route path="*" element={<Navigate to="/" replace />} /> // <-- redirect
</Routes>

score:1


import { 
  BrowserRouter,
  Routes,
  Route
} from 'react-router-dom'
import Footerpage from './components/footerpage/Footerpage';
import Navegation from './components/navegation/Navegation';
import Homepage from './pages/Homepage';
import Contact from './pages/contact/Contact';
import Bookpage from './pages/bookpage/Bookpage';
import Success from './pages/contact/status/Success';
import Error from './pages/contact/status/Error';

function App() {
  return (
    <BrowserRouter>
      <Navegation />
        <Routes>
          <Route path='/' exact element={<Homepage />} />
          <Route path='/contact' exact element={<Contact />} />
          <Route path='/contactsuccess' exact element={<Success />} />
          <Route path='/contacterr' exact element={<Error />} />
          <Route path='/bookpage' exact element={<Bookpage />} />
          <Route element={<Homepage />} />
        </Routes>
      <Footerpage />
    </BrowserRouter>  
  );
}

export default App;

score:1

 <Routes>
      <Route path='/' exact element={<Homepage />} />
      <Route path='/contact' exact element={<Contact />} />
      <Route path='/contactsuccess' exact element={<Success />} />
      <Route path='/contacterr' exact element={<Error />} />
      <Route path='/bookpage' exact element={<Bookpage />} />
      <Route path='/*' element={<Homepage />} />
    </Routes>

Related Query

More Query from same tag