foundation-layout.registerfactory
Home > @genesislcap/foundation-layout > registerFactory
registerFactory() function
Registers a factory function with a unique key. This allows framework components to be used in the declarative layout API without needing to pass function references through HTML attributes.
Signature:
export declare function registerFactory(key: string, factory: ComponentFactory): void;
Parameters
|
Parameter |
Type |
Description |
|---|---|---|
|
key |
string |
Unique identifier for the factory. Should be descriptive and unique across the application. |
|
factory |
The factory function that creates the component. |
Returns:
void
Exceptions
{Error} If a factory with the same key is already registered.
Example
// React example
import { registerFactory } from '@genesislcap/foundation-layout';
import { reactFactory } from './utils/react-layout-factory';
import { MyComponent } from './components/MyComponent';
registerFactory('my-component', reactFactory(MyComponent, { someProp: 'value' }));
Then in your JSX:
<rapid-layout-item
registration="my-item"
title="My Component"
/>