UNPKG

@googleforcreators/react

Version:

A tiny wrapper package that re-exports React and provides additional utilities and custom hooks.

20 lines 903 B
import type { Context } from 'react'; type EqualityFn = (a: unknown, b: unknown) => boolean; /** * This hook returns a part of the context value by selector. * It will trigger a re-render only if the selected value has changed. * * By default, a shallow equals of the selected context value is used to * determine if a re-render is needed. * * @param context Context. * @param selector Returns a fragment of the context * that the consumer is interested in. * @param equalityFn Used to compare the * selected context value. If the context fragment has not changed, a re-render * will not be triggered. This is {shallowEqual} by default. * @return The selected context value fragment. */ declare function useContextSelector<T, S>(context: Context<T>, selector: (value: T) => S, equalityFn?: EqualityFn): S; export default useContextSelector; //# sourceMappingURL=useContextSelector.d.ts.map