UNPKG

@tanstack/vue-router

Version:

Modern and scalable routing for Vue applications

38 lines (37 loc) 1.24 kB
import { CatchBoundary } from "./CatchBoundary.js"; import { useRouter } from "./useRouter.js"; import { isNotFound } from "@tanstack/router-core"; import * as Vue from "vue"; import { useStore } from "@tanstack/vue-store"; //#region src/not-found.tsx function CatchNotFound(props) { const router = useRouter(); const pathname = useStore(router.stores.location, (location) => location.pathname); const status = useStore(router.stores.status, (value) => value); const errorComponentFn = (componentProps) => { const error = componentProps.error; if (isNotFound(error)) { if (props.fallback) return props.fallback(error); return Vue.h("p", null, "Not Found"); } else throw error; }; return Vue.h(CatchBoundary, { getResetKey: () => `not-found-${pathname.value}-${status.value}`, onCatch: (error) => { if (isNotFound(error)) { if (props.onCatch) props.onCatch(error); } else throw error; }, errorComponent: errorComponentFn, children: props.children }); } var DefaultGlobalNotFound = Vue.defineComponent({ name: "DefaultGlobalNotFound", setup() { return () => Vue.h("p", null, "Not Found"); } }); //#endregion export { CatchNotFound, DefaultGlobalNotFound }; //# sourceMappingURL=not-found.js.map