반응형
import { Navigate } from 'react-router-dom';
<Route path="/redirect" element={ <Navigate to="/error-page" /> } />
import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom';
import ErrorPage from './ErrorPage';
import Home from './Home';
function App() {
return (
<BrowserRouter>
<Routes>
<Route
path="/"
element={ <Home /> }
/>
{/* The next line is very important for the Navigate component to work */}
<Route
path="/error-page"
element={ <ErrorPage /> }
/>
<Route
path="/redirect"
element={ <Navigate to="/error-page" /> }
/>
</Routes>
</BrowserRouter>
);
}
export default App;
반응형