Function: defineRegistry()
API / @xmachines/play-react / defineRegistry
function defineRegistry<C>(_catalog, options): DefineRegistryResult;Defined in: @json-render/react
Create a registry from a catalog with components and/or actions.
When the catalog declares actions, the actions field is required.
Type Parameters
| Type Parameter |
|---|
C extends Catalog<SchemaDefinition<SchemaType<string, unknown>, SchemaType<string, unknown>>, unknown> |
Parameters
| Parameter | Type |
|---|---|
_catalog | C |
options | DefineRegistryOptions<C> |
Returns
DefineRegistryResult
Example
// Components only (catalog has no actions)const { registry } = defineRegistry(catalog, { components: { Card: ({ props, children }) => ( <div className="card">{props.title}{children}</div> ), },});
// Both (catalog declares actions)const { registry, handlers, executeAction } = defineRegistry(catalog, { components: { ... }, actions: { ... },});