Skip to content

Commit

Permalink
chore: Opt-in React Router v7 features (#2929)
Browse files Browse the repository at this point in the history
* chore: Opt-in React Router v7 features

Preparations for React Router v7, opts-in the new features to avoid warnings in console.

Related-to vaadin/flow#20527

* fix test

---------

Co-authored-by: Vlad Rindevich <[email protected]>
  • Loading branch information
mshabarov and Lodin committed Dec 9, 2024
1 parent cbd0e07 commit 9993485
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}),
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});

0 comments on commit 9993485

Please sign in to comment.