Home > @pago/reactive > fromHook

fromHook() function

The function passed to fromHook will always be executed when rendering the component.

Signature:

export declare function fromHook<T>(fn: () => T): Ref<T>;

Parameters

Parameter Type Description
fn () => T A callback that uses React Hooks to calculate an observed value.

Returns:

Ref<T>

Example

const screenSize = fromHook(() => useScreenSize());
effect(() => console.log(screenSize.current));