Server: Phase 2 (REVIEW not respected yet)
This commit is contained in:
1 parent
5d16ded553
commit
142b47674d
4271 files changed
+1203269
No files matched your search
+46
@@ -0,0 +1,46 @@
|
||||
import { CatchBoundary } from "./CatchBoundary.js";
|
||||
import { useRouter } from "./useRouter.js";
|
||||
import { isNotFound } from "@tanstack/router-core";
|
||||
import "react";
|
||||
import { isServer } from "@tanstack/router-core/isServer";
|
||||
import { jsx } from "react/jsx-runtime";
|
||||
import { useSelector } from "@tanstack/react-store";
|
||||
//#region src/not-found.tsx
|
||||
function CatchNotFound(props) {
|
||||
const router = useRouter();
|
||||
if (isServer ?? router.isServer) {
|
||||
const resetKey = `not-found-${router.stores.location.get().pathname}-${router.stores.status.get()}`;
|
||||
return /* @__PURE__ */ jsx(CatchBoundary, {
|
||||
getResetKey: () => resetKey,
|
||||
onCatch: (error, errorInfo) => {
|
||||
if (isNotFound(error)) props.onCatch?.(error, errorInfo);
|
||||
else throw error;
|
||||
},
|
||||
errorComponent: ({ error }) => {
|
||||
if (isNotFound(error)) return props.fallback?.(error);
|
||||
else throw error;
|
||||
},
|
||||
children: props.children
|
||||
});
|
||||
}
|
||||
const resetKey = `not-found-${useSelector(router.stores.location, (location) => location.pathname)}-${useSelector(router.stores.status)}`;
|
||||
return /* @__PURE__ */ jsx(CatchBoundary, {
|
||||
getResetKey: () => resetKey,
|
||||
onCatch: (error, errorInfo) => {
|
||||
if (isNotFound(error)) props.onCatch?.(error, errorInfo);
|
||||
else throw error;
|
||||
},
|
||||
errorComponent: ({ error }) => {
|
||||
if (isNotFound(error)) return props.fallback?.(error);
|
||||
else throw error;
|
||||
},
|
||||
children: props.children
|
||||
});
|
||||
}
|
||||
function DefaultGlobalNotFound() {
|
||||
return /* @__PURE__ */ jsx("p", { children: "Not Found" });
|
||||
}
|
||||
//#endregion
|
||||
export { CatchNotFound, DefaultGlobalNotFound };
|
||||
|
||||
//# sourceMappingURL=not-found.js.map
|
||||
Reference in new issue
Block a user