feat(react-router): remove deprecated data in favor of loaderData#14931
feat(react-router): remove deprecated data in favor of loaderData#14931MichaelDeBoey wants to merge 1 commit intov8from
data in favor of loaderData#14931Conversation
|
There was a problem hiding this comment.
Pull request overview
This PR completes the migration started in #14047 by removing the deprecated data field from match/meta-related types and runtime objects, standardizing on loaderData across React Router’s match APIs.
Changes:
- Removed deprecated
datafrom match/meta TypeScript types (MetaMatch,MetaArgs,Match,UIMatch). - Updated runtime match conversion (
convertRouteMatchToUiMatch) to no longer emit adataproperty. - Updated unit and integration tests to assert against
loaderDataonly.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/react-router/lib/types/route-module-annotations.ts | Removes data from match/meta annotation types and updates type-level tests to index loaderData. |
| packages/react-router/lib/router/utils.ts | Removes deprecated UIMatch.data and stops emitting it in convertRouteMatchToUiMatch. |
| packages/react-router/lib/dom/ssr/routeModules.ts | Removes deprecated data from SSR meta types (MetaMatch, MetaArgs). |
| packages/react-router/lib/dom/ssr/components.tsx | Stops passing/setting data in SSR <Meta> wiring; uses loaderData only. |
| packages/react-router/tests/dom/data-static-router-test.tsx | Updates expected useMatches() shapes to exclude data. |
| packages/react-router/tests/data-memory-router-test.tsx | Updates useMatches() assertions to exclude data. |
| integration/matches-test.ts | Updates integration expectations to exclude data. |
| integration/catch-boundary-test.ts | Updates integration expectations to exclude data. |
Comments suppressed due to low confidence (1)
packages/react-router/lib/dom/ssr/routeModules.ts:172
- The
MetaFunctionJSDoc example in this file still references the removeddataargument andmatch.dataproperty (e.g.({ data, matches })andmatches.find(...).data). Since this PR removesdatain favor ofloaderData, those docs should be updated to prevent users from copying broken examples.
export interface MetaArgs<
Loader extends LoaderFunction | ClientLoaderFunction | unknown = unknown,
MatchLoaders extends Record<
string,
LoaderFunction | ClientLoaderFunction | unknown
> = Record<string, unknown>,
> {
loaderData:
| (Loader extends LoaderFunction | ClientLoaderFunction
? SerializeFrom<Loader>
: unknown)
| undefined;
params: Params;
location: Location;
matches: MetaMatches<MatchLoaders>;
error?: unknown;
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
6261caf to
fca625c
Compare
Follow-up of #14047
CC/ @rossipedia