Files
v10/dist/dev/react/hooks/use-snapshot.d.ts
T

24 lines
957 B
TypeScript

import { State } from "../../core/state.js";
import { Comparator, Selector } from "../../core/shallow-equal.js";
import "./use-selector.js";
//#region src/react/hooks/use-snapshot.d.ts
/**
* Subscribe to a State container's current value.
*
* @param state - The State container to subscribe to.
* @param selector - Derives a value from state.
* @param isEqual - Custom equality function. Defaults to `shallowEqual`.
*/
/** @label Without Selector */
declare function useSnapshot<T extends object>(state: State<T>): T;
/**
* Select a value from state. Re-renders when the selected value changes.
*
* @label With Selector
* @param selector - Derives a value from state.
* @param isEqual - Custom equality function. Defaults to `shallowEqual`.
*/
declare function useSnapshot<T extends object, R>(state: State<T>, selector: Selector<T, R>, isEqual?: Comparator<R>): R;
//#endregion
export { useSnapshot };
//# sourceMappingURL=use-snapshot.d.ts.map