diff --git a/config/jest.setup.cjs b/config/jest.setup.cjs new file mode 100644 index 0000000..196808c --- /dev/null +++ b/config/jest.setup.cjs @@ -0,0 +1,4 @@ +// eslint-disable-next-line @typescript-eslint/no-require-imports +const { TextEncoder, TextDecoder } = require('util'); +global.TextEncoder = TextEncoder; +global.TextDecoder = TextDecoder; diff --git a/jest.config.mjs b/jest.config.mjs index 34d259d..e363e47 100644 --- a/jest.config.mjs +++ b/jest.config.mjs @@ -1,5 +1,6 @@ export default { roots: [''], + setupFiles: ['/config/jest.setup.cjs'], moduleFileExtensions: ['ts', 'tsx', 'js', 'json', 'jsx'], transform: { '^.+\\.(js|jsx|ts|tsx)$': [ diff --git a/package.json b/package.json index 4d8f0ff..fdce8d5 100755 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ "react-dom": "^18.3.1", "react-i18next": "^15.0.1", "react-redux": "^9.1.2", - "react-router-dom": "^6.26.1", + "react-router": "^7.0.1", "reset-css": "^5.0.1", "serialize-javascript": "^6.0.0" }, @@ -94,7 +94,6 @@ "@types/qs": "^6.9.15", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", - "@types/react-router-dom": "^5.1.0", "@types/serialize-javascript": "^5.0.0", "autoprefixer": "^10.4.20", "browser-sync": "^3.0.2", diff --git a/src/App.tsx b/src/App.tsx index 3aeb84f..87380de 100755 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,4 +1,4 @@ -import { Route, Routes } from 'react-router-dom'; +import { Route, Routes } from 'react-router'; import { renderNestedRoutes } from 'src/helpers'; import routes from 'src/routes'; diff --git a/src/components/layouts/main.tsx b/src/components/layouts/main.tsx index 4396b1c..6b97142 100644 --- a/src/components/layouts/main.tsx +++ b/src/components/layouts/main.tsx @@ -1,6 +1,6 @@ import loadable from '@loadable/component'; import { useEffect, useState } from 'react'; -import { useLocation, Outlet } from 'react-router-dom'; +import { useLocation, Outlet } from 'react-router'; import { Header } from 'src/components/molecules/Header/Header'; import { setOverflow } from 'src/helpers'; import { emitter, TOGGLE_MODAL } from 'src/libs/emitter'; diff --git a/src/components/molecules/Link/Link.tsx b/src/components/molecules/Link/Link.tsx index 4aba4d9..b59708a 100644 --- a/src/components/molecules/Link/Link.tsx +++ b/src/components/molecules/Link/Link.tsx @@ -1,8 +1,8 @@ -import { NavLink, matchPath } from 'react-router-dom'; +import { NavLink, matchPath } from 'react-router'; import routes from 'src/routes'; import type { FunctionComponent, MouseEventHandler } from 'react'; -import type { NavLinkProps } from 'react-router-dom'; +import type { NavLinkProps } from 'react-router'; export const Link: FunctionComponent = ({ style, diff --git a/src/helpers/index.tsx b/src/helpers/index.tsx index 8414d20..333b7f4 100755 --- a/src/helpers/index.tsx +++ b/src/helpers/index.tsx @@ -1,5 +1,5 @@ import qs from 'qs'; -import { Route } from 'react-router-dom'; +import { Route } from 'react-router'; import path from 'path'; diff --git a/src/hooks/useInitialState.ts b/src/hooks/useInitialState.ts index 9185ce6..965a5b5 100644 --- a/src/hooks/useInitialState.ts +++ b/src/hooks/useInitialState.ts @@ -1,5 +1,5 @@ import { useEffect } from 'react'; -import { useLocation } from 'react-router-dom'; +import { useLocation } from 'react-router'; import { useDispatch, useSelector } from 'src/hooks/redux'; import type { ActionCreatorWithoutPayload } from '@reduxjs/toolkit'; diff --git a/src/root/client.tsx b/src/root/client.tsx index 82444b4..0fff7ff 100755 --- a/src/root/client.tsx +++ b/src/root/client.tsx @@ -5,7 +5,7 @@ import Fetch from 'i18next-http-backend'; import { hydrateRoot } from 'react-dom/client'; import { withSSR, initReactI18next } from 'react-i18next'; import { Provider } from 'react-redux'; -import { BrowserRouter } from 'react-router-dom'; +import { BrowserRouter } from 'react-router'; import { App } from 'src/App'; import { initializeState } from 'src/store'; diff --git a/src/root/server.tsx b/src/root/server.tsx index dd5a9f6..1736c38 100644 --- a/src/root/server.tsx +++ b/src/root/server.tsx @@ -5,8 +5,7 @@ import Backend from 'i18next-http-backend'; import { renderToString } from 'react-dom/server'; import { I18nextProvider, initReactI18next } from 'react-i18next'; import { Provider } from 'react-redux'; -import { matchPath } from 'react-router-dom'; -import { StaticRouter } from 'react-router-dom/server'; +import { matchPath, StaticRouter } from 'react-router'; import serialize from 'serialize-javascript'; import { App } from 'src/App'; import { expandNestedRoutes } from 'src/helpers'; diff --git a/yarn.lock b/yarn.lock index c93d494..1f2d56a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1978,11 +1978,6 @@ redux-thunk "^3.1.0" reselect "^5.1.0" -"@remix-run/router@1.21.0": - version "1.21.0" - resolved "https://registry.yarnpkg.com/@remix-run/router/-/router-1.21.0.tgz#c65ae4262bdcfe415dbd4f64ec87676e4a56e2b5" - integrity sha512-xfSkCAchbdG5PnbrKqFWwia4Bi61nH+wm8wLEqfHDyp7Y3dZzgqS2itV8i4gAq9pC2HsTpwyBC6Ds8VHZ96JlA== - "@rsdoctor/client@0.4.8": version "0.4.8" resolved "https://registry.yarnpkg.com/@rsdoctor/client/-/client-0.4.8.tgz#c9d50cae4e14d6d155a9013566e0637aca751680" @@ -2610,6 +2605,11 @@ resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.4.1.tgz#bfd02c1f2224567676c1545199f87c3a861d878d" integrity sha512-XW/Aa8APYr6jSVVA1y/DEIZX0/GMKLEVekNG727R8cs56ahETkRAy/3DR7+fJyh7oUgGwNQaRfXCun0+KbWY7Q== +"@types/cookie@^0.6.0": + version "0.6.0" + resolved "https://registry.yarnpkg.com/@types/cookie/-/cookie-0.6.0.tgz#eac397f28bf1d6ae0ae081363eca2f425bedf0d5" + integrity sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA== + "@types/cors@^2.8.12": version "2.8.17" resolved "https://registry.yarnpkg.com/@types/cors/-/cors-2.8.17.tgz#5d718a5e494a8166f569d986794e49c48b216b2b" @@ -2702,11 +2702,6 @@ dependencies: "@types/node" "*" -"@types/history@^4.7.11": - version "4.7.11" - resolved "https://registry.yarnpkg.com/@types/history/-/history-4.7.11.tgz#56588b17ae8f50c53983a524fc3cc47437969d64" - integrity sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA== - "@types/http-errors@*": version "2.0.4" resolved "https://registry.yarnpkg.com/@types/http-errors/-/http-errors-2.0.4.tgz#7eb47726c391b7345a6ec35ad7f4de469cf5ba4f" @@ -2859,23 +2854,6 @@ dependencies: "@types/react" "*" -"@types/react-router-dom@^5.1.0": - version "5.3.3" - resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-5.3.3.tgz#e9d6b4a66fcdbd651a5f106c2656a30088cc1e83" - integrity sha512-kpqnYK4wcdm5UaWI3fLcELopqLrHgLqNsdpHauzlQktfkHL3npOSwtj1Uz9oKBAzs7lFtVkV8j83voAz2D8fhw== - dependencies: - "@types/history" "^4.7.11" - "@types/react" "*" - "@types/react-router" "*" - -"@types/react-router@*": - version "5.1.20" - resolved "https://registry.yarnpkg.com/@types/react-router/-/react-router-5.1.20.tgz#88eccaa122a82405ef3efbcaaa5dcdd9f021387c" - integrity sha512-jGjmu/ZqS7FjSH6owMcD5qpq19+1RS9DeVRqfl1FeBMxTDQAGwlMWOcs52NDoXaNKyG3d1cYQFMs9rCrb88o9Q== - dependencies: - "@types/history" "^4.7.11" - "@types/react" "*" - "@types/react@*", "@types/react@^18.3.3": version "18.3.12" resolved "https://registry.yarnpkg.com/@types/react/-/react-18.3.12.tgz#99419f182ccd69151813b7ee24b792fe08774f60" @@ -8354,20 +8332,15 @@ react-refresh@^0.14.2: resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.14.2.tgz#3833da01ce32da470f1f936b9d477da5c7028bf9" integrity sha512-jCvmsr+1IUSMUyzOkRcvnVbX3ZYC6g9TDrDbFuFmRDq7PD4yaGbLKNQL6k2jnArV8hjYxh7hVhAZB6s9HDGpZA== -react-router-dom@^6.26.1: - version "6.28.0" - resolved "https://registry.yarnpkg.com/react-router-dom/-/react-router-dom-6.28.0.tgz#f73ebb3490e59ac9f299377062ad1d10a9f579e6" - integrity sha512-kQ7Unsl5YdyOltsPGl31zOjLrDv+m2VcIEcIHqYYD3Lp0UppLjrzcfJqDJwXxFw3TH/yvapbnUvPlAj7Kx5nbg== - dependencies: - "@remix-run/router" "1.21.0" - react-router "6.28.0" - -react-router@6.28.0: - version "6.28.0" - resolved "https://registry.yarnpkg.com/react-router/-/react-router-6.28.0.tgz#29247c86d7ba901d7e5a13aa79a96723c3e59d0d" - integrity sha512-HrYdIFqdrnhDw0PqG/AKjAqEqM7AvxCz0DQ4h2W8k6nqmc5uRBYDag0SBxx9iYz5G8gnuNVLzUe13wl9eAsXXg== +react-router@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/react-router/-/react-router-7.0.1.tgz#a171e35a5c6463f76b23353c4ce57b53c8b7b1b9" + integrity sha512-WVAhv9oWCNsja5AkK6KLpXJDSJCQizOIyOd4vvB/+eHGbYx5vkhcmcmwWjQ9yqkRClogi+xjEg9fNEOd5EX/tw== dependencies: - "@remix-run/router" "1.21.0" + "@types/cookie" "^0.6.0" + cookie "^1.0.1" + set-cookie-parser "^2.6.0" + turbo-stream "2.4.0" react@^18.3.1: version "18.3.1" @@ -9704,6 +9677,11 @@ tslib@^2.0.0, tslib@^2.0.3, tslib@^2.1.0, tslib@^2.6.2: resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== +turbo-stream@2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/turbo-stream/-/turbo-stream-2.4.0.tgz#1e4fca6725e90fa14ac4adb782f2d3759a5695f0" + integrity sha512-FHncC10WpBd2eOmGwpmQsWLDoK4cqsA/UT/GqNoaKOQnT8uzhtCbg3EoUDMvqpOSAI0S26mr0rkjzbOO6S3v1g== + type-check@^0.4.0, type-check@~0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"