Function: useWand()
ts
function useWand<E, P>(options?, ref?):
| Wand<ComposeConfig<[...E[], ...P[]]>>
| null;Defined in: react/index.ts:51
Create a wand when the component mounts, and destroy the wand when the component unmounts.
The hook reads effects, plugins, providers and target one time. To change them, remount the component with a new key. When config changes, the hook compares each section and calls setConfig with the changed sections.
Type Parameters
| Type Parameter | Default type |
|---|---|
E extends readonly Effect<string, Schema>[] | DefaultEffects |
P extends readonly Plugin<string, Schema>[] | [] |
Parameters
| Parameter | Type | Description |
|---|---|---|
options | CreateWandOptions<E, P> | The options of createWand. |
ref? | WandTargetRef | A ref to the container element. If you give it, the wand uses container mode. |
Returns
| Wand<ComposeConfig<[...E[], ...P[]]>> | null
The wand, or null before the first effect runs.
Example
ts
const ref = useRef<HTMLDivElement>(null);
const wand = useWand({ config: { chalk: { size: size } } }, ref);