Skip to content

Commit 7d3174a

Browse files
authored
perf: avoid unnecessary data router re-renders (#15376)
1 parent da2a0f0 commit 7d3174a

13 files changed

Lines changed: 912 additions & 283 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Switch to more granular internal router contexts to avoid unnecessary route component re-renders when unrelated data router state changes
2+
3+
- ⚠️ This contains some breaking changes to exported `UNSAFE_` contexts, so please review carefully if you are using those unsafe exports

packages/react-router/__tests__/data-memory-router-test.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -797,15 +797,7 @@ describe("createMemoryRouter", () => {
797797

798798
spy.mockClear();
799799
fireEvent.click(screen.getByText("Link to Bar"));
800-
expect(spy).toHaveBeenCalledWith("Layout", [
801-
{
802-
data: undefined,
803-
handle: undefined,
804-
id: "0",
805-
params: {},
806-
pathname: "/",
807-
},
808-
]);
800+
expect(spy).not.toHaveBeenCalled();
809801

810802
spy.mockClear();
811803
await waitFor(() => screen.getByText("Bar"));

0 commit comments

Comments
 (0)