Advertisement
Guest User

Untitled

a guest
Dec 28th, 2022
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import ReactDOM from "react-dom/client";
  2.  
  3. import {
  4.     BrowserRouter,
  5.     Route,
  6.     Routes
  7. } from 'react-router-dom';
  8.  
  9. function Home(props) {
  10.     return (
  11.         <h1>This is the Homepage.</h1>
  12.     );
  13. }
  14.  
  15. function About(props) {
  16.     return (
  17.         <h1>This is the About page.</h1>
  18.     )
  19. }
  20.  
  21. function Error(props) {
  22.     return (
  23.         <h1>Error 404. This page does not exist.</h1>
  24.     );
  25. }
  26.  
  27. function App(props) {
  28.     return (
  29.         <BrowserRouter>
  30.             <Routes>
  31.                 <Route path='/'>
  32.                     <Home />
  33.                 </Route>
  34.  
  35.                 <Route path='about'>
  36.                     <About />
  37.                 </Route>
  38.  
  39.                 <Route path='*'>
  40.                     <Error />
  41.                 </Route>
  42.             </Routes>
  43.         </BrowserRouter>
  44.     );
  45. }
  46.  
  47. const root = ReactDOM.createRoot(document.getElementById('root'));
  48. root.render(<App />);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement