From 4ec4f1ebd0ca2a7bef210bdbde0dfb5372b3cf96 Mon Sep 17 00:00:00 2001 From: Mikhail Shabarov <61410877+mshabarov@users.noreply.github.com> Date: Wed, 11 Dec 2024 19:11:34 +0200 Subject: [PATCH] chore: Opt-in React Router v7 features (#2929) (CP: 24.5) (#2967) --- .../src/runtime/RouterConfigurationBuilder.ts | 17 ++++++++++++++++- .../runtime/RouterConfigurationBuilder.spec.tsx | 16 +++++++++++++++- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/ts/file-router/src/runtime/RouterConfigurationBuilder.ts b/packages/ts/file-router/src/runtime/RouterConfigurationBuilder.ts index d62a762560..6215ff7e82 100644 --- a/packages/ts/file-router/src/runtime/RouterConfigurationBuilder.ts +++ b/packages/ts/file-router/src/runtime/RouterConfigurationBuilder.ts @@ -322,7 +322,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, + }), }; } } diff --git a/packages/ts/file-router/test/runtime/RouterConfigurationBuilder.spec.tsx b/packages/ts/file-router/test/runtime/RouterConfigurationBuilder.spec.tsx index 1c4d7eff33..511b5cb80a 100644 --- a/packages/ts/file-router/test/runtime/RouterConfigurationBuilder.spec.tsx +++ b/packages/ts/file-router/test/runtime/RouterConfigurationBuilder.spec.tsx @@ -528,7 +528,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(); }); });