From bc0071d721e427b5a4fcb2119a56e4b2c4cc5170 Mon Sep 17 00:00:00 2001 From: Matt Brophy Date: Mon, 15 May 2023 10:02:21 -0400 Subject: [PATCH] Fix basename duplication in RouterProvider descendant routes --- .changeset/fix-basename-duplication.md | 5 + .../__tests__/useNavigate-test.tsx | 175 ++++++++++++++++++ packages/react-router/lib/hooks.tsx | 19 +- 3 files changed, 194 insertions(+), 5 deletions(-) create mode 100644 .changeset/fix-basename-duplication.md diff --git a/.changeset/fix-basename-duplication.md b/.changeset/fix-basename-duplication.md new file mode 100644 index 0000000000..13c1963ed1 --- /dev/null +++ b/.changeset/fix-basename-duplication.md @@ -0,0 +1,5 @@ +--- +"react-router": patch +--- + +Fix `basename` duplication in descenant `` inside a `` diff --git a/packages/react-router/__tests__/useNavigate-test.tsx b/packages/react-router/__tests__/useNavigate-test.tsx index 3e3dead5b4..4512c03c5f 100644 --- a/packages/react-router/__tests__/useNavigate-test.tsx +++ b/packages/react-router/__tests__/useNavigate-test.tsx @@ -2053,6 +2053,181 @@ describe("useNavigate", () => { `); }); }); + + describe("with a basename", () => { + describe("in a MemoryRouter", () => { + it("in a root route", () => { + let renderer: TestRenderer.ReactTestRenderer; + TestRenderer.act(() => { + renderer = TestRenderer.create( + + + } /> + Path} /> + + + ); + }); + + function Home() { + let navigate = useNavigate(); + return