Skip to content
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

Allow returning undefined from loaders/actions (part 2) #12057

Merged
merged 6 commits into from
Oct 3, 2024

Conversation

brophdawg11
Copy link
Contributor

@brophdawg11 brophdawg11 commented Oct 2, 2024

Follow up to #11680 which missed some of the Remix codepath checks.

Copy link

changeset-bot bot commented Oct 2, 2024

🦋 Changeset detected

Latest commit: b05d129

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

This PR includes changesets to release 10 packages
Name Type
react-router Major
@react-router/architect Major
@react-router/cloudflare Major
@react-router/dev Major
react-router-dom Major
@react-router/express Major
@react-router/node Major
@react-router/serve Major
@react-router/fs-routes Major
@react-router/remix-config-routes-adapter Major

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

@@ -832,7 +832,7 @@ export function _renderMatches(
let { loaderData, errors } = dataRouterState;
let needsToRunLoader =
match.route.loader &&
loaderData[match.route.id] === undefined &&
!(match.route.id in loaderData) &&
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The presence of the key in loaderData/actionData now indicates if it ran or not

@@ -20,61 +20,18 @@ export interface AppLoadContext {
*/
export type AppData = unknown;

export async function callRouteAction({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Once the undefined check was removed there was no difference left between callRouteLoader and callRouteAction so they are now collapsed to callRouteHandler

@@ -770,6 +770,10 @@ const defaultMapRouteProperties: MapRoutePropertiesFunction = (route) => ({

const TRANSITIONS_STORAGE_KEY = "remix-router-transitions";

// Flag used on new `loaderData` to indicate that we do not want to preserve
// any prior loader data from the throwing route in `mergeLoaderData`
const ResetLoaderDataSymbol = Symbol("ResetLoaderData");
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We used to use undefined to detect this scenario, switched to a symbol since undefined is a valid value now

@brophdawg11 brophdawg11 merged commit 91a7fdc into dev Oct 3, 2024
8 checks passed
@brophdawg11 brophdawg11 deleted the brophdawg11/allow-undefined branch October 3, 2024 13:05
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