creativetimofficial / argon-dashboard-react

React version of Argon Dashboard
MIT License
443 stars 739 forks source link

Updating for react router v6 #74

Closed ktwbc closed 1 year ago

ktwbc commented 1 year ago

The following changes can be made for this template for react-router v6

for each route in routes.js change component to element and make it a bracket element such as

{
    path: '/index',
    name: 'Dashboard',
    icon: 'ni ni-tv-2 text-primary',
    element: <Index />,
    layout: '/admin'
  },

Instances of getRoutes() should use path/element and remove the "prop.layout +" when building path since they're now relative.

const getRoutes = (routes) => {
    return routes.map((prop, key) => {
      if (prop.layout === '/auth') {
        return <Route path={prop.path} element={prop.element} key={key} />;
      } else {
        return null;
      }
    });
  };

Then change instances of to and rewrite all 's to a Route/Navigate such as <Route path="/" element={<Navigate to="/admin/index" />} />

github-actions[bot] commented 1 year ago

@ktwbc this issue was automatically closed because it did not follow our rules:


IMPORTANT: Please use the following link to create a new issue:

https://www.creative-tim.com/new-issue/argon-dashboard-react

**If your issue was not created using the app above, it will be closed immediately.**

Love Creative Tim? Do you need Angular, React, Vuejs or HTML? You can visit:
👉  https://www.creative-tim.com/bundles
👉  https://www.creative-tim.com