import React from 'react';
      import { Routes, Route, Navigate } from 'react-router-dom';
      import App from 'pages/App';
      const Router = () => {
        return (
            <Route path="/" element={<App />}>
              <Route index element={<Navigate to="home" />} />
      export default Router;
      Javascript language logo
      your recipe card header background

      React create Router component react-router-dom

      React JavaScript Recipes

      The above code creates a class that is a router. Inside the class, we have a single route, which is the path "/". This route has a route component that is a element. The index route is also created, and this route has a component.

      Library: react

      Shortcut: react.router.create


      • avatar

        juanfrank77 6/23/2022, 3:51:27 PM


        This one is a very useful snippet for React Router.

      Add Comment

      Log in to add a comment

      Codiga - All rights reserved 2022.