UNPKG

slate-react

Version:

Tools for building completely customizable richtext editors with React.

20 lines 828 B
/** * Create a selector that updates when an `update` function is called, and * which only causes the component to render when the result of `selector` * differs from the previous result according to `equalityFn`. * * If `selector` is memoized using `useCallback`, then it will only be called * when it changes or when `update` is called. Otherwise, `selector` will be * called every time the component renders. * * @example * const [state, update] = useGenericSelector(selector, equalityFn) * * useIsomorphicLayoutEffect(() => { * return addEventListener(update) * }, [addEventListener, update]) * * return state */ export declare function useGenericSelector<T>(selector: () => T, equalityFn: (a: T | null, b: T) => boolean): [state: T, update: () => void]; //# sourceMappingURL=use-generic-selector.d.ts.map