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

chore: React Router v7 #20537

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Outlet } from 'react-router-dom';
import { Outlet } from 'react-router';
import { ReactAdapterElement } from "Frontend/generated/flow/ReactAdapter.js";
import React from "react";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public class TaskGenerateReactFiles

OR

import { createBrowserRouter, RouteObject } from 'react-router-dom';
import { createBrowserRouter, RouteObject } from 'react-router';
import { serverSideRoutes } from 'Frontend/generated/flow/Flow';

function build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ import {
useLocation,
useNavigate,
type NavigateOptions,
} from "react-router-dom";
import type { AgnosticRouteObject } from '@remix-run/router';
} from "react-router";
import type { AgnosticRouteObject } from 'react-router';
import { createPortal } from "react-dom";

const flow = new _Flow({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"dependencies": {
"react": "18.3.1",
"react-dom": "18.3.1",
"react-router-dom": "6.28.0"
"react-router": "7.0.0"
},
"devDependencies": {
"@types/react": "18.3.12",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

import { createElement } from 'react';
import { createRoot } from 'react-dom/client';
import { RouterProvider } from 'react-router-dom';
import { RouterProvider } from 'react-router';
import { router } from '%routesJsImportPath%';

function App() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* `src/main/frontend/views/` directory, this route configuration is
* re-generated automatically by Vaadin.
******************************************************************************/
import { createBrowserRouter, RouteObject } from 'react-router-dom';
import { createBrowserRouter, RouteObject } from 'react-router';
import { serverSideRoutes } from 'Frontend/generated/flow/Flow';

function build() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2135,7 +2135,7 @@ public void defaultProdBundleExists_noCompressedProdBundleFile_noBuildRequired()
FileUtils.write(packageJson,
"{\"dependencies\": {" + " \"react\": \"18.2.0\",\n"
+ " \"react-dom\": \"18.2.0\",\n"
+ " \"react-router-dom\": \"6.18.0\"}, "
+ " \"react-router\": \"7.0.0\"}, "
+ "\"vaadin\": { \"hash\": \"aHash\"} }",
StandardCharsets.UTF_8);

Expand Down Expand Up @@ -2171,7 +2171,7 @@ public void defaultProdBundleExists_noCompressedProdBundleFileAndWithVersionsJso
FileUtils.write(packageJson,
"{\"dependencies\": {" + " \"react\": \"18.2.0\",\n"
+ " \"react-dom\": \"18.2.0\",\n"
+ " \"react-router-dom\": \"6.18.0\"}, "
+ " \"react-router\": \"7.0.0\"}, "
+ "\"vaadin\": { \"hash\": \"aHash\"} }",
StandardCharsets.UTF_8);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public class FrontendUtilsTest {
import MainLayout from 'Frontend/views/MainLayout';
import ContactsView from 'Frontend/views/ContactsView';
import AboutView from 'Frontend/views/AboutView';
import { RouteObject } from 'react-router-dom';
import { RouteObject } from 'react-router';

export const routes: RouteObject[] = [
{
Expand All @@ -163,7 +163,7 @@ public class FrontendUtilsTest {
import MainLayout from 'Frontend/views/MainLayout';
import ContactsView from 'Frontend/views/ContactsView';
import AboutView from 'Frontend/views/AboutView';
import { RouteObject } from 'react-router-dom';
import { RouteObject } from 'react-router';

export const routes: RouteObject[] = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public void getDefaultDependencies_includesAllDependencies() {
expectedDependencies.add("lit");
expectedDependencies.add("react");
expectedDependencies.add("react-dom");
expectedDependencies.add("react-router-dom");
expectedDependencies.add("react-router");

Set<String> actualDependendencies = defaultDeps.keySet();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void routesContainMultipleFlowImports_noExceptionThrown()
String content = """
import HelloWorldView from 'Frontend/views/helloworld/HelloWorldView.js';
import MainLayout from 'Frontend/views/MainLayout.js';
import { createBrowserRouter, RouteObject } from 'react-router-dom';
import { createBrowserRouter, RouteObject } from 'react-router';
import { tea, serverSideRoutes, coffee } from "Frontend/generated/flow/Flow";
import LoginView from "Frontend/views/LoginView";

Expand Down Expand Up @@ -223,7 +223,7 @@ public void routesMissingImportAndUsage_noBuildOrServerSideRoutes_exceptionThrow
String content = """
import HelloWorldView from 'Frontend/views/helloworld/HelloWorldView.js';
import MainLayout from 'Frontend/views/MainLayout.js';
import { createBrowserRouter, RouteObject } from 'react-router-dom';
import { createBrowserRouter, RouteObject } from 'react-router';
import { tea, coffee } from "Frontend/generated/flow/Flow";
import LoginView from "Frontend/views/LoginView";

Expand Down Expand Up @@ -260,7 +260,7 @@ public void routesMissingImport_exceptionThrown() throws IOException {
import HelloWorldView from 'Frontend/views/helloworld/HelloWorldView.js';
import MainLayout from 'Frontend/views/MainLayout.js';
import { lazy } from 'react';
import { createBrowserRouter, RouteObject } from 'react-router-dom';
import { createBrowserRouter, RouteObject } from 'react-router';
import {protectRoutes} from "@hilla/react-auth";
import LoginView from "Frontend/views/LoginView";

Expand Down Expand Up @@ -298,7 +298,7 @@ public void missingImport_noServerRoutesDefined_noExceptionThrown()
import HelloWorldView from 'Frontend/views/helloworld/HelloWorldView.js';
import MainLayout from 'Frontend/views/MainLayout.js';
import { lazy } from 'react';
import { createBrowserRouter, RouteObject } from 'react-router-dom';
import { createBrowserRouter, RouteObject } from 'react-router';
import {protectRoutes} from "@hilla/react-auth";
import LoginView from "Frontend/views/LoginView";

Expand Down Expand Up @@ -583,4 +583,4 @@ private class TestRoute extends Component {
@Layout("/test")
private class TestLayout extends Component implements RouterLayout {
}
}
}
Loading