Skip to content

Commit 6076a1e

Browse files
committed
Inline detectAndHandle405Error
1 parent d5ec922 commit 6076a1e

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

packages/react-router/lib/router/router.ts

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2311,19 +2311,6 @@ export function createRouter(init: RouterInit): Router {
23112311
interruptActiveLoads();
23122312
fetchLoadMatches.delete(key);
23132313

2314-
function detectAndHandle405Error(m: AgnosticDataRouteMatch) {
2315-
if (!m.route.action && !m.route.lazy) {
2316-
let error = getInternalRouterError(405, {
2317-
method: submission.formMethod,
2318-
pathname: path,
2319-
routeId: routeId,
2320-
});
2321-
setFetcherError(key, routeId, error, { flushSync });
2322-
return true;
2323-
}
2324-
return false;
2325-
}
2326-
23272314
// Put this fetcher into it's submitting state
23282315
let existingFetcher = state.fetchers.get(key);
23292316
updateFetcherState(key, getSubmittingFetcher(submission, existingFetcher), {
@@ -2366,7 +2353,13 @@ export function createRouter(init: RouterInit): Router {
23662353

23672354
let match = getTargetMatch(requestMatches, path);
23682355

2369-
if (detectAndHandle405Error(match)) {
2356+
if (!match.route.action && !match.route.lazy) {
2357+
let error = getInternalRouterError(405, {
2358+
method: submission.formMethod,
2359+
pathname: path,
2360+
routeId: routeId,
2361+
});
2362+
setFetcherError(key, routeId, error, { flushSync });
23702363
return;
23712364
}
23722365

0 commit comments

Comments
 (0)