Errors and code splitting API
Error boundaries and lazy component contracts for pending, failure, and loaded states.
Errors and code splitting exports
12 public exports, grouped under their canonical import boundary.
@tavojs/core
Canonical import boundary for every symbol in this section.
ErrorBoundary#
ErrorBoundary(props: ErrorBoundaryProps): ErrorBoundaryVNodeCreates an error boundary vnode that captures descendant render errors.
Related guideErrorBoundaryProps#
type ErrorBoundaryProps = {
children?: Child;
fallback: ErrorBoundaryFallback;
resetKey?: unknown;
};Defines the props accepted by error boundary in the application runtime.
Related guidelazy#
lazy<P extends Record<string, unknown> = Record<string, unknown>>(loader: LazyLoader<P>, options?: LazyOptions | undefined): LazyComponent<P>Creates a component that loads its implementation with a dynamic import on first render.
Related guideLazyComponent#
type LazyComponent<P extends Record<string, unknown>> = Component<P> & {
preload(): Promise<Component<P>>;
getStatus(): LazyStatus<P>;
};Defines the lazy component contract used by the application runtime.
Related guideLazyErrorFallback#
type LazyErrorFallback = Child | ((state: LazyErrorState) => Child);Defines the lazy error fallback contract used by the application runtime.
Related guideLazyErrorState#
type LazyErrorState = {
status: "error";
error: unknown;
};Represents the observable state of lazy error in the application runtime.
Related guideLazyFallback#
type LazyFallback = Child | ((state: LazyPendingState) => Child);Defines the lazy fallback contract used by the application runtime.
Related guideLazyLoader#
type LazyLoader<P extends Record<string, unknown>> = () => Promise<LazyModule<P>>;Defines the lazy loader contract used by the application runtime.
Related guideLazyModule#
type LazyModule<P extends Record<string, unknown>> = Component<P> | {
default: Component<P>;
};Defines the lazy module contract used by the application runtime.
Related guideLazyOptions#
type LazyOptions = {
fallback?: LazyFallback;
errorFallback?: LazyErrorFallback;
};Configures lazy in the application runtime.
Related guideLazyPendingState#
type LazyPendingState = {
status: "idle" | "loading";
};Represents the observable state of lazy pending in the application runtime.
Related guideLazyStatus#
type LazyStatus<P extends Record<string, unknown>> = {
status: "idle";
component: null;
error: null;
} | {
status: "loading";
component: null;
error: null;
} | {
status: "loaded";
component: Component<P>;
error: null;
} | {
status: "error";
component: null;
error: unknown;
};Defines the lazy status contract used by the application runtime.
Related guide