@tanstack/vue-router
Version:
Modern and scalable routing for Vue applications
50 lines (49 loc) • 1.44 kB
JavaScript
import { CatchBoundary } from "./CatchBoundary.js";
import { useRouter } from "./useRouter.js";
import { isNotFound } from "@tanstack/router-core";
import * as Vue from "vue";
import { useSelector } from "@tanstack/vue-store";
//#region src/not-found.tsx
var CatchNotFound = Vue.defineComponent({
name: "CatchNotFound",
inheritAttrs: false,
props: {
fallback: Function,
onCatch: Function,
children: {
type: Object,
required: true
}
},
setup(props) {
const router = useRouter();
const pathname = useSelector(router.stores.location, (location) => location.pathname);
const status = useSelector(router.stores.status);
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