diff --git a/generators/react/resources/package.json b/generators/react/resources/package.json index dd7034421839..95e2372fae02 100644 --- a/generators/react/resources/package.json +++ b/generators/react/resources/package.json @@ -16,7 +16,7 @@ "react-loadable": "5.5.0", "react-redux": "9.1.2", "react-redux-loading-bar": "5.0.8", - "react-router-dom": "6.28.0", + "react-router-dom": "7.0.1", "react-toastify": "10.0.6", "react-transition-group": "4.4.5", "reactstrap": "9.2.3", @@ -60,6 +60,7 @@ "identity-obj-proxy": "3.0.0", "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", + "jest-fixed-jsdom": "0.0.9", "jest-junit": "16.0.0", "jest-sonar": "0.2.16", "json-loader": "0.5.7", diff --git a/generators/react/templates/jest.conf.js.ejs b/generators/react/templates/jest.conf.js.ejs index d05d739aad6a..9ea403198a3a 100644 --- a/generators/react/templates/jest.conf.js.ejs +++ b/generators/react/templates/jest.conf.js.ejs @@ -1,7 +1,7 @@ const tsconfig = require('./tsconfig.test.json'); module.exports = { - testEnvironment: 'jsdom', + testEnvironment: 'jest-fixed-jsdom', transform: { '^.+\\.tsx?$': [ 'ts-jest', diff --git a/generators/react/templates/package.json.ejs b/generators/react/templates/package.json.ejs index 64cb4e7dd075..86af79b57e6d 100644 --- a/generators/react/templates/package.json.ejs +++ b/generators/react/templates/package.json.ejs @@ -86,6 +86,7 @@ "identity-obj-proxy": "<%= nodeDependencies['identity-obj-proxy'] %>", "jest": "<%= nodeDependencies['jest'] %>", "jest-environment-jsdom": "<%= nodeDependencies['jest-environment-jsdom'] %>", + "jest-fixed-jsdom": "<%= nodeDependencies['jest-fixed-jsdom'] %>", "jest-junit": "<%= nodeDependencies['jest-junit'] %>", "jest-sonar": "<%= nodeDependencies['jest-sonar'] %>", "json-loader": "<%= nodeDependencies['json-loader'] %>", diff --git a/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/index.tsx.ejs b/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/index.tsx.ejs index 9edb36060146..35d51dadf205 100644 --- a/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/index.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/entities/_entityFolder_/index.tsx.ejs @@ -17,7 +17,7 @@ limitations under the License. -%> import React from 'react'; -import { Route } from 'react-router-dom'; +import { Route } from 'react-router'; import ErrorBoundaryRoutes from 'app/shared/error/error-boundary-routes'; diff --git a/generators/react/templates/src/main/webapp/app/entities/routes.tsx.ejs b/generators/react/templates/src/main/webapp/app/entities/routes.tsx.ejs index 3ceb6404f320..20d850a936d0 100644 --- a/generators/react/templates/src/main/webapp/app/entities/routes.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/entities/routes.tsx.ejs @@ -17,7 +17,7 @@ limitations under the License. -%> import React from 'react'; -import { Route } from 'react-router-dom'; +import { Route } from 'react-router'; import ErrorBoundaryRoutes from 'app/shared/error/error-boundary-routes'; diff --git a/generators/react/templates/src/main/webapp/app/modules/account/index.tsx.ejs b/generators/react/templates/src/main/webapp/app/modules/account/index.tsx.ejs index 73c8f7a0c6ad..2681057c0a3f 100644 --- a/generators/react/templates/src/main/webapp/app/modules/account/index.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/modules/account/index.tsx.ejs @@ -17,7 +17,7 @@ limitations under the License. -%> import React from 'react'; -import { Route } from 'react-router-dom'; +import { Route } from 'react-router'; import ErrorBoundaryRoutes from 'app/shared/error/error-boundary-routes'; diff --git a/generators/react/templates/src/main/webapp/app/modules/administration/index.tsx.ejs b/generators/react/templates/src/main/webapp/app/modules/administration/index.tsx.ejs index a63e04c8575f..798f1f39040d 100644 --- a/generators/react/templates/src/main/webapp/app/modules/administration/index.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/modules/administration/index.tsx.ejs @@ -18,7 +18,7 @@ -%> import React from 'react'; -import { Route } from 'react-router-dom'; +import { Route } from 'react-router'; import ErrorBoundaryRoutes from 'app/shared/error/error-boundary-routes'; <%_ if (generateUserManagement) { _%> import UserManagement from './user-management'; diff --git a/generators/react/templates/src/main/webapp/app/modules/administration/user-management/index.tsx.ejs b/generators/react/templates/src/main/webapp/app/modules/administration/user-management/index.tsx.ejs index 3158d8b1358f..bba8d3da5fd9 100644 --- a/generators/react/templates/src/main/webapp/app/modules/administration/user-management/index.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/modules/administration/user-management/index.tsx.ejs @@ -17,7 +17,7 @@ limitations under the License. -%> import React from 'react'; -import { Route } from 'react-router-dom'; +import { Route } from 'react-router'; import ErrorBoundaryRoutes from 'app/shared/error/error-boundary-routes'; import UserManagement from './user-management'; diff --git a/generators/react/templates/src/main/webapp/app/routes.tsx.ejs b/generators/react/templates/src/main/webapp/app/routes.tsx.ejs index d1e36a71769e..4d9be8404062 100644 --- a/generators/react/templates/src/main/webapp/app/routes.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/routes.tsx.ejs @@ -17,7 +17,10 @@ limitations under the License. -%> import React<% if (applicationTypeGateway && microfrontend) { %>, { Suspense }<% } %> from 'react'; -import { Route <% if (communicationSpringWebsocket) { %>, useLocation <% } %>} from 'react-router-dom'; +import { Route } from 'react-router'; +<% if (communicationSpringWebsocket) { %> +import { useLocation } from 'react-router-dom'; +<% } %> import Loadable from 'react-loadable'; <%_ if (applicationTypeGateway && microfrontend) { _%> import { importRemote } from '@module-federation/utilities'; diff --git a/generators/react/templates/src/main/webapp/app/shared/auth/private-route.spec.tsx.ejs b/generators/react/templates/src/main/webapp/app/shared/auth/private-route.spec.tsx.ejs index 7dc12af1abb5..7fce75591377 100644 --- a/generators/react/templates/src/main/webapp/app/shared/auth/private-route.spec.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/shared/auth/private-route.spec.tsx.ejs @@ -1,5 +1,5 @@ import React from 'react'; -import { MemoryRouter, Route, Routes } from 'react-router-dom'; +import { MemoryRouter, Route, Routes } from 'react-router'; import { render } from '@testing-library/react'; <%_ if (enableTranslation) { _%> import { TranslatorContext } from 'react-jhipster'; diff --git a/generators/react/templates/src/main/webapp/app/shared/error/error-boundary-routes.spec.tsx.ejs b/generators/react/templates/src/main/webapp/app/shared/error/error-boundary-routes.spec.tsx.ejs index bf14ce279452..4a077c9b268e 100644 --- a/generators/react/templates/src/main/webapp/app/shared/error/error-boundary-routes.spec.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/shared/error/error-boundary-routes.spec.tsx.ejs @@ -1,5 +1,5 @@ import React from 'react'; -import { MemoryRouter, Route } from 'react-router-dom'; +import { MemoryRouter, Route } from 'react-router'; import { render } from '@testing-library/react'; import ErrorBoundaryRoutes from './error-boundary-routes'; diff --git a/generators/react/templates/src/main/webapp/app/shared/error/error-boundary-routes.tsx.ejs b/generators/react/templates/src/main/webapp/app/shared/error/error-boundary-routes.tsx.ejs index 689608cf014b..5bffbf476946 100644 --- a/generators/react/templates/src/main/webapp/app/shared/error/error-boundary-routes.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/shared/error/error-boundary-routes.tsx.ejs @@ -1,5 +1,6 @@ import React from 'react'; -import { Outlet, Route, Routes, RoutesProps } from 'react-router-dom'; +import { Routes, Route } from 'react-router'; +import { Outlet, RoutesProps } from 'react-router-dom'; import ErrorBoundary from 'app/shared/error/error-boundary'; const ErrorBoundaryRoutes = ({ children }: RoutesProps) => { diff --git a/generators/react/templates/src/main/webapp/app/shared/layout/header/header.spec.tsx.ejs b/generators/react/templates/src/main/webapp/app/shared/layout/header/header.spec.tsx.ejs index 3cd7ebc93fd9..1756b1b375f0 100644 --- a/generators/react/templates/src/main/webapp/app/shared/layout/header/header.spec.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/shared/layout/header/header.spec.tsx.ejs @@ -19,7 +19,7 @@ import React from 'react'; import { render } from '@testing-library/react'; import { Provider } from 'react-redux'; -import { MemoryRouter } from 'react-router-dom'; +import { MemoryRouter } from 'react-router'; import initStore from 'app/config/store'; import Header from './header'; diff --git a/generators/react/templates/src/main/webapp/app/shared/layout/menus/account.spec.tsx.ejs b/generators/react/templates/src/main/webapp/app/shared/layout/menus/account.spec.tsx.ejs index b0fc945da892..6622e556e641 100644 --- a/generators/react/templates/src/main/webapp/app/shared/layout/menus/account.spec.tsx.ejs +++ b/generators/react/templates/src/main/webapp/app/shared/layout/menus/account.spec.tsx.ejs @@ -18,7 +18,7 @@ -%> import React from 'react'; import { render } from '@testing-library/react'; -import { MemoryRouter } from 'react-router-dom'; +import { MemoryRouter } from 'react-router'; <%_ if (authenticationTypeOauth2) { _%>