-
-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Fix RSC fetcher.load
#13709
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
Fix RSC fetcher.load
#13709
Conversation
|
@@ -2258,7 +2258,6 @@ export function createRouter(init: RouterInit): Router { | |||
return; | |||
} | |||
|
|||
let match = getTargetMatch(matches, path); |
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.
In the fog of war case, this match
is completely ignored and is reassigned once route discovery is done. In an RSC world, if the the root route doesn't have a path, this line throws an error even though its result would never have been used.
To fix this, the creation of this match
variable is delayed until after route discovery has completed and we know for a fact we have valid matches. This also means we no longer pass it as an argument to handleFetcherLoader
and handleFetcherAction
.
if (!match.route.action && !match.route.lazy) { | ||
let error = getInternalRouterError(405, { | ||
method: submission.formMethod, | ||
pathname: path, | ||
routeId: routeId, | ||
}); | ||
setFetcherError(key, routeId, error, { flushSync }); | ||
return; | ||
} |
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 detectAndHandle405Error
function has been inlined now that this logic is only needed in a single place.
No description provided.