UNPKG

fluidstate-preact

Version:

Library for using fine-grained reactivity state management library fluidstate in Preact

16 lines (15 loc) 888 B
import { Signal } from "@preact/signals"; import { Context } from "preact"; /** * A Preact hook that bridges `fluidstate` reactivity with `@preact/signals`. * It returns a `get` function that can be used to create memoized Preact signals * from `fluidstate` reactive state. This is the most performant way to use * `fluidstate` in Preact, as it avoids component re-renders and updates only * the specific parts of the DOM that depend on the state. * * @param Context - Optional. A Preact Context object. If provided, the state * from this context will be available to the selector functions passed to `get`. * This is typically used with `createReactiveSetup`. * @returns A `get` function that takes a selector and returns a Preact Signal. */ export declare const useSignals: <ContextValue>(Context?: Context<ContextValue>) => <T>(fn: (value: ContextValue) => T) => Signal<T>;