Skip to main content

StateDefinitionBoundary

class

Retries the mod component when a State it read becomes defined, and shows the failure on screen while it is broken. A mod can declare a new owned State and read it from its view in one edit. The bundle carrying the reader travels a different channel than the extension host's definition commit, and the view's rehydrate can only report what the host holds at that instant — so the reader can render before the definition exists and throw. Without this boundary that throw kills the React root and the view stays dead until the window reloads, which is the whole point of the live loop lost for the edit a mod author is most likely to make. Remounting on the definition signal is targeted rather than merely tolerant: the definition set is the input the failed render was missing, so its arrival is the one event that can make the same render succeed. A failure that the definition signal never resolves is a real bug in the mod, and rendering nothing for it is what makes every mod failure look identical from the outside. The message is painted into the view itself, because the author is looking at the view — not at a diagnostics channel they would have to know exists. Reporting through `onError` continues regardless.

class StateDefinitionBoundary

Import

import { StateDefinitionBoundary } from '@modular/sdk/view';

Members6

state
StateDefinitionBoundaryState
componentDidCatch
(error: Error, info: ErrorInfo) => void

Catches exceptions generated in descendant components. Unhandled exceptions will cause the entire component tree to unmount.

componentDidMount
() => void

Called immediately after a component is mounted. Setting state here will trigger re-rendering.

componentWillUnmount
() => void

Called immediately before a component is destroyed. Perform any necessary cleanup in this method, such as cancelled network requests, or cleaning up any DOM elements created in `componentDidMount`.

getDerivedStateFromError
(error: unknown) => Partial<StateDefinitionBoundaryState>
render
() => ReactNode