-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Allow returning undefined from loaders/actions (part 2) #12057
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
Conversation
🦋 Changeset detectedLatest commit: b05d129 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 packages
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 |
packages/react-router/lib/hooks.tsx
Outdated
@@ -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) && |
There was a problem hiding this comment.
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
a92cb5c
to
17dca50
Compare
@@ -20,61 +20,18 @@ export interface AppLoadContext { | |||
*/ | |||
export type AppData = unknown; | |||
|
|||
export async function callRouteAction({ |
There was a problem hiding this comment.
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"); |
There was a problem hiding this comment.
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
0e77363
to
f4aebf9
Compare
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Follow up to #11680 which missed some of the Remix codepath checks.