UNPKG

fluidstate-react

Version:

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

15 lines (14 loc) 779 B
/** * A React hook that runs a function to derive state from reactive sources * and automatically re-renders the component when any of the accessed * reactive properties change. * * @template T The type of the derived state. * @param {() => T} getState A function that accesses reactive state and returns a value. * This function is re-executed whenever its reactive dependencies change. * @param {ReadonlyArray<unknown>} [dependencyArray=[]] An optional array of dependencies, * similar to `useMemo` or `useEffect`. The `getState` function will be re-created * if any of these dependencies change. * @returns {T} The result of the `getState` function. */ export declare const useReactive: <T>(getState: () => T, dependencyArray?: ReadonlyArray<unknown>) => T;