Skip to content

Add lazy route definition support with cached async children resolution#143

Closed
Copilot wants to merge 4 commits intomasterfrom
copilot/implement-lazy-route-definition
Closed

Add lazy route definition support with cached async children resolution#143
Copilot wants to merge 4 commits intomasterfrom
copilot/implement-lazy-route-definition

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 7, 2026

  • Review new PR comments and identify actionable code changes.
  • Update Router route-change tracking to avoid reading refs during render.
  • Remove lazy-cache dependency hack by replacing it with explicit state-driven recomputation.
  • Run targeted router tests for lazy routes and type checks.
  • Run code review and CodeQL checks, then reply to addressed comments.
Original prompt

Please implement the lazy route definition feature based on the design doc which is already committed.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: uhyo <748348+uhyo@users.noreply.github.com>
Copilot AI changed the title [WIP] Implement lazy route definition feature based on design doc Add lazy route definition support with cached async children resolution Mar 7, 2026
Copilot finished work on behalf of uhyo March 7, 2026 01:38
() => new Map<InternalRouteDefinition, Promise<void>>(),
);
const previousRoutesRef = useRef(routes);
if (previousRoutesRef.current !== routes) {
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reading ref during rendering is against rules; use a state instead, not ref

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated this in 9e07cae. I removed the render-time ref comparison and switched routes-change handling to effect-driven lazy-cache reset.

// Match routes and execute loaders
const matchedRoutesWithData = useMemo(() => {
// Recompute this memo when lazy cache identity changes after lazy children resolution.
void lazyCache;
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No hack like this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 9e07cae. I removed the lazy-cache dependency hack and kept rerender-on-lazy-resolution via explicit lazyCache state updates.

Copilot AI and others added 2 commits March 7, 2026 02:13
Co-authored-by: uhyo <748348+uhyo@users.noreply.github.com>
Co-authored-by: uhyo <748348+uhyo@users.noreply.github.com>
Copilot finished work on behalf of uhyo March 7, 2026 02:17
@uhyo uhyo closed this Mar 7, 2026
@uhyo uhyo deleted the copilot/implement-lazy-route-definition branch March 7, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants