Skip to content

Commit 9c160ef

Browse files
committed
Revert "Update dependencies and refactor AppStateProvider to utilize react-router-dom for URL parameter handling"
This reverts commit 6fef33c.
1 parent 6fef33c commit 9c160ef

File tree

3 files changed

+9
-76
lines changed

3 files changed

+9
-76
lines changed

package-lock.json

-68
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
"express": "4.21.1",
1818
"react": "18.3.1",
1919
"react-dom": "18.3.1",
20-
"react-router-dom": "7.0.2",
2120
"swr": "2.2.5"
2221
},
2322
"devDependencies": {
@@ -28,10 +27,10 @@
2827
"@typescript-eslint/parser": "8.9.0",
2928
"@vitejs/plugin-react": "4.3.3",
3029
"eslint": "8.57.1",
31-
"eslint-plugin-css-modules": "2.12.0",
3230
"eslint-plugin-react": "7.37.1",
3331
"eslint-plugin-react-hooks": "5.0.0",
3432
"eslint-plugin-react-refresh": "0.4.12",
33+
"eslint-plugin-css-modules": "2.12.0",
3534
"npm-run-all": "4.1.5",
3635
"prettier": "3.3.3",
3736
"rollup-plugin-visualizer": "5.12.0",

xp-archive/client/context/appState/AppStateProvider.tsx

+8-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import React, { useCallback, useMemo, useState, useEffect } from 'react';
22
import { AppStateContext } from './AppStateContext';
33
import { Locale } from 'client/contentTree/NavigationBar';
4-
import { useParams } from 'react-router-dom';
54

65
type Props = {
76
children: React.ReactNode;
@@ -17,14 +16,17 @@ export const AppStateProvider = ({ children }: Props) => {
1716
const [selectedLocale, setSelectedLocale] = useState<Locale>('no');
1817
const [selectedVersion, setSelectedVersion] = useState<SelectedVersion>();
1918

20-
const { contentId, locale } = useParams<{ contentId: string; locale: Locale }>();
21-
19+
// Parse URL on mount
2220
useEffect(() => {
23-
if (contentId && locale) {
21+
const path = window.location.pathname;
22+
const matches = path.match(/\/xp\/([^\/]+)\/([^\/]+)/);
23+
24+
if (matches) {
25+
const [, contentId, locale] = matches;
2426
setSelectedContentId(contentId);
25-
setSelectedLocale(locale);
27+
setSelectedLocale(locale as Locale);
2628
}
27-
}, [contentId, locale]);
29+
}, []);
2830

2931
const updateSelectedContent = useCallback(
3032
(selectedContent: string) => {

0 commit comments

Comments
 (0)