Skip to content

Stop inserting null placeholders for non-executed loaders in staticHandler.query #13223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 9, 2025

Conversation

brophdawg11
Copy link
Contributor

@brophdawg11 brophdawg11 commented Mar 13, 2025

Do not add null to staticHandler.query() loaderData if routes do not have loaders

This was an implementation detail required in Remix v2 because we used JSON.stringify() to serialize the loaderData of the client and it would strip undefined values which would cause issues for client-side router hydration. This should have been removed in React Router v7 because Single Fetch does not have the same restrictions but it was missed.

We used to check loaderData[routeId] !== undefined to see if a given route already had any data or not. Once we began allowing loaders to return undefined, our check of loaderData[routeId] !== undefined was no longer valid and we adjusted to a check of routeId in loaderData. This check can produce false positives if null values are inserted.

⚠️ This could be a "breaking bug fix" for manual SSR with createStaticHandler()/<StaticRouterProvider>, and using context.loaderData to control <RouterProvider> hydration behavior on the client.

Copy link

changeset-bot bot commented Mar 13, 2025

🦋 Changeset detected

Latest commit: 4df618a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 11 packages
Name Type
react-router Patch
@react-router/architect Patch
@react-router/cloudflare Patch
@react-router/dev Patch
react-router-dom Patch
@react-router/express Patch
@react-router/node Patch
@react-router/serve Patch
@react-router/fs-routes Patch
@react-router/remix-routes-option-adapter Patch
create-react-router Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brophdawg11 brophdawg11 marked this pull request as draft March 17, 2025 17:27
@brophdawg11 brophdawg11 force-pushed the brophdawg11/remove-null-data branch from 1270bf3 to a706d24 Compare April 9, 2025 14:22
@brophdawg11 brophdawg11 marked this pull request as ready for review April 9, 2025 14:52
@brophdawg11 brophdawg11 merged commit aae4b2c into dev Apr 9, 2025
5 checks passed
@brophdawg11 brophdawg11 deleted the brophdawg11/remove-null-data branch April 9, 2025 15:35
Copy link
Contributor

🤖 Hello there,

We just published version 7.5.1-pre.0 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 7.5.1 which includes this pull request. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant