Router: change the Switch component to a Routes component

In React Router v6 the Switch element is replaced by Routes. All links
inside a <Routes> are relative and routes can be placed in any order
now.
This commit is contained in:
Jacob Kozol 2021-11-16 21:54:30 +01:00 committed by jkozol
parent b34f655524
commit c6f2ed227f
2 changed files with 6 additions and 6 deletions

View file

@ -1,6 +1,6 @@
import React, { useEffect, useState } from 'react';
import { useHistory } from 'react-router-dom';
import { Routes } from './Routes';
import { Router } from './Router';
import '@patternfly/patternfly/patternfly-addons.css';
import './App.scss';
@ -38,7 +38,7 @@ const App = (props) => {
return (
<React.Fragment>
<NotificationsPortal />
{ permission ? <Routes childProps={ props } /> : <PermissionDenied /> }
{ permission ? <Router childProps={ props } /> : <PermissionDenied /> }
</React.Fragment>
);
};

View file

@ -1,15 +1,15 @@
import React, { lazy } from 'react';
import { Route, Switch, Redirect } from 'react-router-dom';
import { Route, Routes, Redirect } from 'react-router-dom';
const LandingPage = lazy(() => import('./Components/LandingPage/LandingPage'));
const CreateImageWizard = lazy(() => import('./Components/CreateImageWizard/CreateImageWizard'));
export const Routes = () => {
export const Router = () => {
return (
<Switch>
<Routes>
<Route exact path='/landing' component={ LandingPage } />
<Route exact path='/imagewizard' component={ CreateImageWizard } />
<Redirect to='/landing' />
</Switch>
</Routes>
);
};