Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@
- nichtsam
- nikeee
- nilubisan
- Nirva-Software
- Nismit
- nnhjs
- noisypigeon
Expand Down
19 changes: 19 additions & 0 deletions packages/react-router/__tests__/router/lazy-discovery-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -999,9 +999,18 @@ describe("Lazy Route Discovery (Fog of War)", () => {
expect(router.state.initialized).toBe(false);
expect(router.state.matches.map((m) => m.route.id)).toEqual(["parent"]);

expect(router.state.navigation).toMatchObject({
state: "loading",
location: { pathname: "/parent/child" },
});

loaderDfd.resolve("PARENT");
expect(router.state.initialized).toBe(false);
expect(router.state.matches.map((m) => m.route.id)).toEqual(["parent"]);
expect(router.state.navigation).toMatchObject({
state: "loading",
location: { pathname: "/parent/child" },
});

childrenDfd.resolve([
{
Expand All @@ -1012,8 +1021,17 @@ describe("Lazy Route Discovery (Fog of War)", () => {
]);
expect(router.state.initialized).toBe(false);
expect(router.state.matches.map((m) => m.route.id)).toEqual(["parent"]);
expect(router.state.navigation).toMatchObject({
state: "loading",
location: { pathname: "/parent/child" },
});

childLoaderDfd.resolve("CHILD");

expect(router.state.navigation).toMatchObject({
state: "loading",
location: { pathname: "/parent/child" },
});
await tick();
expect(router.state.initialized).toBe(true);
expect(router.state.location.pathname).toBe("/parent/child");
Expand All @@ -1025,6 +1043,7 @@ describe("Lazy Route Discovery (Fog of War)", () => {
"parent",
"child",
]);
expect(router.state.navigation).toMatchObject(IDLE_NAVIGATION);
});

it("discovers routes during initial SPA renders when a splat route matches", async () => {
Expand Down
2 changes: 2 additions & 0 deletions packages/react-router/lib/router/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,8 @@ export function createRouter(init: RouterInit): Router {
flushSync,
},
);
} else if (initialMatchesIsFOW) {
updateState({ navigation: loadingNavigation }, { flushSync });
}

let discoverResult = await discoverRoutes(
Expand Down