Skip to content

Commit a69ddf1

Browse files
committed
Add comments
1 parent ffe8a1f commit a69ddf1

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/react-router/lib/router/router.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4868,10 +4868,15 @@ async function loadLazyRouteModule(
48684868
return;
48694869
}
48704870

4871+
// We use `.then` to chain additional logic to the lazy route promise so that
4872+
// the consumer's lazy route logic is coupled to our logic for updating the
4873+
// route in place in a single task. This ensures that the cached promise
4874+
// contains all logic for managing the lazy route. This chained promise is
4875+
// then awaited so that consumers of this function see the updated route.
48714876
let lazyRoutePromise = route.lazy().then((lazyRoute) => {
4872-
// Update the route in place. This should be safe because there's no way
4873-
// we could yet be sitting on this route as we can't get there without
4874-
// resolving lazy() first.
4877+
// Here we update the route in place. This should be safe because there's
4878+
// no way we could yet be sitting on this route as we can't get there
4879+
// without resolving lazy() first.
48754880
//
48764881
// This is different than the HMR "update" use-case where we may actively be
48774882
// on the route being updated. The main concern boils down to "does this

0 commit comments

Comments
 (0)