Add lazy route definition support with cached async children resolution#143
Closed
Add lazy route definition support with cached async children resolution#143
Conversation
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
uhyo
requested changes
Mar 7, 2026
packages/router/src/Router/index.tsx
Outdated
| () => new Map<InternalRouteDefinition, Promise<void>>(), | ||
| ); | ||
| const previousRoutesRef = useRef(routes); | ||
| if (previousRoutesRef.current !== routes) { |
Owner
There was a problem hiding this comment.
Reading ref during rendering is against rules; use a state instead, not ref
Contributor
Author
There was a problem hiding this comment.
Updated this in 9e07cae. I removed the render-time ref comparison and switched routes-change handling to effect-driven lazy-cache reset.
packages/router/src/Router/index.tsx
Outdated
| // Match routes and execute loaders | ||
| const matchedRoutesWithData = useMemo(() => { | ||
| // Recompute this memo when lazy cache identity changes after lazy children resolution. | ||
| void lazyCache; |
Contributor
Author
There was a problem hiding this comment.
Addressed in 9e07cae. I removed the lazy-cache dependency hack and kept rerender-on-lazy-resolution via explicit lazyCache state updates.
Co-authored-by: uhyo <748348+uhyo@users.noreply.github.com>
Co-authored-by: uhyo <748348+uhyo@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.