Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade-react-router #36

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"react-dropzone": "^12.0.4",
"react-icons": "^4.3.1",
"react-is": "^18.0.0",
"react-router-dom": "^5.3.0",
"react-router-dom": "^6.0.0",
"react-scripts": "5.0.0",
"react-table": "^7.7.0",
"stylis": "^4.1.1",
Expand Down
32 changes: 16 additions & 16 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import ReactDOM from 'react-dom';
import 'assets/css/App.css';
import { HashRouter, Route, Switch, Redirect } from 'react-router-dom';
import { Routes, Route, Navigate, BrowserRouter } from 'react-router-dom';
import AuthLayout from 'layouts/auth';
import AdminLayout from 'layouts/admin';
import RtlLayout from 'layouts/rtl';
Expand All @@ -10,19 +10,19 @@ import theme from 'theme/theme';
import { ThemeEditorProvider } from '@hypertheme-editor/chakra-ui';

ReactDOM.render(
<ChakraProvider theme={theme}>
<React.StrictMode>
<ThemeEditorProvider>
<HashRouter>
<Switch>
<Route path={`/auth`} component={AuthLayout} />
<Route path={`/admin`} component={AdminLayout} />
<Route path={`/rtl`} component={RtlLayout} />
<Redirect from='/' to='/admin' />
</Switch>
</HashRouter>
</ThemeEditorProvider>
</React.StrictMode>
</ChakraProvider>,
document.getElementById('root')
<ChakraProvider theme={theme}>
<React.StrictMode>
<ThemeEditorProvider>
<BrowserRouter>
<Routes>
<Route path="/auth/*" element={<AuthLayout />} />
<Route path="/admin/*" element={<AdminLayout />} />
<Route path="/rtl/*" element={<RtlLayout />} />
<Route path="/" element={<Navigate to="/admin" />} />
</Routes>
</BrowserRouter>
</ThemeEditorProvider>
</React.StrictMode>
</ChakraProvider>,
document.getElementById('root')
);
8 changes: 4 additions & 4 deletions src/layouts/admin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Navbar from 'components/navbar/NavbarAdmin.js';
import Sidebar from 'components/sidebar/Sidebar.js';
import { SidebarContext } from 'contexts/SidebarContext';
import React, { useState } from 'react';
import { Redirect, Route, Switch } from 'react-router-dom';
import { Navigate, Route, Routes } from 'react-router-dom';
import routes from 'routes.js';

// Custom Chakra theme
Expand Down Expand Up @@ -138,10 +138,10 @@ export default function Dashboard(props) {

{getRoute() ? (
<Box mx='auto' p={{ base: '20px', md: '30px' }} pe='20px' minH='100vh' pt='50px'>
<Switch>
<Routes>
{getRoutes(routes)}
<Redirect from='/' to='/admin/default' />
</Switch>
<Route path="/" element={<Navigate to="/admin/default" />} />
</Routes>
</Box>
) : null}
<Box>
Expand Down
12 changes: 4 additions & 8 deletions src/layouts/auth/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useState } from "react";
import { Redirect, Route, Switch } from "react-router-dom";
import { Navigate, Route, Routes } from "react-router-dom";
import routes from "routes.js";

// Chakra imports
Expand Down Expand Up @@ -59,14 +59,10 @@ export default function Auth() {
transitionTimingFunction='linear, linear, ease'>
{getRoute() ? (
<Box mx='auto' minH='100vh'>
<Switch>
<Routes>
{getRoutes(routes)}
<Redirect
from='/auth'
to='/auth/sign-in/default
'
/>
</Switch>
<Route path="/auth" element={<Navigate to="/auth/sign-in/default" />} />
</Routes>
</Box>
) : null}
</Box>
Expand Down
8 changes: 4 additions & 4 deletions src/layouts/rtl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import Sidebar from "components/sidebar/Sidebar.js";
import { RtlProvider } from "components/rtlProvider/RtlProvider.js";
import { SidebarContext } from "contexts/SidebarContext";
import React, { useState } from "react";
import { Redirect, Route, Switch } from "react-router-dom";
import { Navigate , Route, Routes } from "react-router-dom";
import routes from "routes.js";

// Custom Chakra theme
Expand Down Expand Up @@ -154,10 +154,10 @@ export default function Dashboard(props) {
pe='20px'
minH='100vh'
pt='50px'>
<Switch>
<Routes>
{getRoutes(routes)}
<Redirect from='/' to='/rtl/default' />
</Switch>
<Route path="/" element={<Navigate to="/rtl/default" />} />
</Routes>
</Box>
) : null}
<Box>
Expand Down