From e9b63dcb164149b271225d7ec7d514c62ce70a54 Mon Sep 17 00:00:00 2001 From: Mikhail Shabarov Date: Wed, 27 Nov 2024 09:34:58 +0200 Subject: [PATCH 1/2] chore: Opt-in React Router v7 features Preparations for React Router v7, opts-in the new features to avoid warnings in console. Related-to https://github.com/vaadin/flow/issues/20527 --- .../src/runtime/RouterConfigurationBuilder.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/packages/ts/file-router/src/runtime/RouterConfigurationBuilder.ts b/packages/ts/file-router/src/runtime/RouterConfigurationBuilder.ts index 553080c49..754fc690d 100644 --- a/packages/ts/file-router/src/runtime/RouterConfigurationBuilder.ts +++ b/packages/ts/file-router/src/runtime/RouterConfigurationBuilder.ts @@ -324,7 +324,22 @@ export class RouterConfigurationBuilder { return { routes, - router: createBrowserRouter([...routes], { basename: new URL(document.baseURI).pathname, ...options }), + router: createBrowserRouter([...routes], { + basename: new URL(document.baseURI).pathname, + future: { + // eslint-disable-next-line camelcase + v7_fetcherPersist: true, + // eslint-disable-next-line camelcase + v7_normalizeFormMethod: true, + // eslint-disable-next-line camelcase + v7_partialHydration: true, + // eslint-disable-next-line camelcase + v7_relativeSplatPath: true, + // eslint-disable-next-line camelcase + v7_skipActionErrorRevalidation: true, + }, + ...options, + }), }; } From 2049be4f112f378a0bd4dae3814d5870fd913ca0 Mon Sep 17 00:00:00 2001 From: Mikhail Shabarov Date: Wed, 27 Nov 2024 14:26:33 +0200 Subject: [PATCH 2/2] fix test --- .../runtime/RouterConfigurationBuilder.spec.tsx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/ts/file-router/test/runtime/RouterConfigurationBuilder.spec.tsx b/packages/ts/file-router/test/runtime/RouterConfigurationBuilder.spec.tsx index 53ef943bc..f25710c0e 100644 --- a/packages/ts/file-router/test/runtime/RouterConfigurationBuilder.spec.tsx +++ b/packages/ts/file-router/test/runtime/RouterConfigurationBuilder.spec.tsx @@ -690,7 +690,21 @@ describe('RouterBuilder', () => { const { routes, router } = builder.build(); expect(router).to.equal(browserRouter); - expect(createBrowserRouter).to.have.been.calledWith(routes, { basename: '/foo' }); + expect(createBrowserRouter).to.have.been.calledWith(routes, { + basename: '/foo', + future: { + // eslint-disable-next-line camelcase + v7_fetcherPersist: true, + // eslint-disable-next-line camelcase + v7_normalizeFormMethod: true, + // eslint-disable-next-line camelcase + v7_partialHydration: true, + // eslint-disable-next-line camelcase + v7_relativeSplatPath: true, + // eslint-disable-next-line camelcase + v7_skipActionErrorRevalidation: true, + }, + }); reset(); }); });