Describe what a route's loaders resolve to - #812
Open
pleek91 wants to merge 1 commit into
Open
Conversation
RouteDataOf combines the loaders of every match, so a child sees an ancestor's data as its own, and flattens to the loader's data directly when the only loader in the tree is unnamed. Carried by ResolvedRouteWithData rather than by ResolvedRoute: only the route being navigated to has data, so a route the router merely resolved would carry a promise that could never settle.
stackoverfloweth
force-pushed
the
route-data
branch
from
August 6, 2026 14:18
b331cbd to
b8d66aa
Compare
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.
Description
Fifth step of #805, stacked on #811. Types only.
RouteDataOfcombines the loaders of every match, so a child sees an ancestor's data as its own, and flattens to the loader's data directly when the only loader in the tree is unnamed:Data is always a promise, even for a synchronous loader. Loaders do not hold up rendering, so a component reading data cannot be given a settled value — making that uniform is cheaper than making it conditional.
It is carried by
ResolvedRouteWithDatarather than byResolvedRoute, because only the route being navigated to has data. A route the router merely resolved —router.resolve,router.find, theto/froma hook receives — is not being loaded, so data on it could only be a promise that never settles. #814 gives it to the two surfaces that do have it: the current route, and a props getter's route.Also worth a look: the unregistered case types data as
Promise<unknown> | Record<string, Promise<unknown>> | undefinedrather than just a record, because a route whose data is a bare promise has to satisfy the constraint.