Skip to content

Commit

Permalink
fix: use react-router-dom-v5-compat for compatibility with react 18
Browse files Browse the repository at this point in the history
This package allows to run both v6 and v5 together. Through this
package, we are now able to migrate to v6 incrementally.
Once everything has been migrated, the package can be removed and
react-router-dom can be upgraded to v6.

Refs: SHELL-258 (#541)
  • Loading branch information
beawar authored Nov 12, 2024
1 parent cf232ae commit 6c6bb57
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 17 deletions.
41 changes: 41 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@
"react-dom": "^18.3.1",
"react-i18next": "^12.3.1",
"react-router-dom": "^5.3.4",
"react-router-dom-v5-compat": "^6.28.0",
"styled-components": "^5.3.11",
"tinymce": "^6.8.4",
"ua-parser-js": "^1.0.37",
Expand Down
37 changes: 20 additions & 17 deletions src/boot/bootstrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import React, { useEffect } from 'react';

import { SnackbarManager } from '@zextras/carbonio-design-system';
import { BrowserRouter, Route, Switch, useParams } from 'react-router-dom';
import { CompatRouter } from 'react-router-dom-v5-compat';

import AppLoaderMounter from './app/app-loader-mounter';
import { DefaultViewsRegister } from './app/default-views';
Expand All @@ -33,23 +34,25 @@ const Bootstrapper = (): React.JSX.Element => (
<ThemeProvider>
<ShellI18nextProvider>
<BrowserRouter basename={BASENAME}>
<TrackerProvider>
<SnackbarManager>
<Loader />
{IS_FOCUS_MODE && (
<Switch>
<Route path={'/:route'}>
<FocusModeListener />
</Route>
</Switch>
)}
<DefaultViewsRegister />
<NotificationPermissionChecker />
<ContextBridge />
<AppLoaderMounter />
<ShellView />
</SnackbarManager>
</TrackerProvider>
<CompatRouter>
<TrackerProvider>
<SnackbarManager>
<Loader />
{IS_FOCUS_MODE && (
<Switch>
<Route path={'/:route'}>
<FocusModeListener />
</Route>
</Switch>
)}
<DefaultViewsRegister />
<NotificationPermissionChecker />
<ContextBridge />
<AppLoaderMounter />
<ShellView />
</SnackbarManager>
</TrackerProvider>
</CompatRouter>
</BrowserRouter>
</ShellI18nextProvider>
</ThemeProvider>
Expand Down

0 comments on commit 6c6bb57

Please sign in to comment.