@prismrepo/react
Optional React integration, PrismProvider and usePrismRegistry. Full public export list.
Depends only on @prismrepo/core and React. Never react-hook-form,
zod, or any adapter package, see
Package Responsibilities.
PrismProvider
function PrismProvider<TRegistry extends object>(props: {
registry: TRegistry;
children?: ReactNode;
}): ReactNode;Makes registry available to descendants via usePrismRegistry. A convenience, not a
requirement: usePrismForm takes a FormDefinition that
already carries its own registry, so it works without a PrismProvider at all. Use this when
you want a registry available ambiently across part of a tree instead of threading it through
props.
Two PrismProviders anywhere in the tree, nested or sibling, are fully independent: each
creates its own context value, and a descendant always reads the nearest enclosing provider,
never a different one.
The registry is memoized by reference, not recomputed structurally, so an unrelated prop
changing on PrismProvider does not create a new context value and does not re-render
consumers that only read the registry.
usePrismRegistry()
function usePrismRegistry<TRegistry extends object>(): TRegistry;Reads the registry from the nearest enclosing PrismProvider. Throws
PrismConfigurationError if called outside one, rather than silently returning undefined.
TRegistry is supplied explicitly by the caller (usePrismRegistry<typeof myRegistry>()),
there's nothing at the call site to infer it from, the same pattern React Hook Form's own
useForm<TValues>() uses.