-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Open
Description
Which project does this relate to?
Start
Describe the bug
I have a route that declares a server function as loader and a notFoundComponent.
The server function throws notFound().
import { createFileRoute, notFound } from "@tanstack/react-router";
import { createServerFn } from "@tanstack/react-start";
const loaderServerFn = createServerFn().handler(() => {
throw notFound();
});
export const Route = createFileRoute("/")({
loader: async () => await loaderServerFn(),
component: RouteComponent,
notFoundComponent: NotFoundComponent,
});
function NotFoundComponent() {
return <span>NotFoundComponent</span>;
}
function RouteComponent() {
return <span>RouteComponent</span>;
}It shows NotFoundComponent as expected when initially navigating to it. When saving the file again in VSCode and therefore triggering an hot module replacement event in the browser, the route crashes with following error:
{"isNotFound":true}
Your Example Website or App
https://github.com/ulrichstark/tanstack-repro-isNotFound-on-hmr
Steps to Reproduce the Bug or Issue
git clone https://github.com/ulrichstark/tanstack-repro-isNotFound-on-hmr
cd tanstack-repro-isNotFound-on-hmr
npm i
npx viteThen go to /src/routes/index.tsx and hit save to trigger hmr.
Expected behavior
NotFoundComponent should still be shown after hmr.
Screenshots or Videos
No response
Platform
- Router / Start Version: 1.134.12
Additional context
Maybe similar to #5322
coderabbitai
Metadata
Metadata
Assignees
Labels
No labels