import { ComponentType, FC, useEffect } from 'react'; export declare const withSSR: (cb: () => R) => R; export declare const useIsomorphicLayoutEffect: typeof useEffect; export interface VendorContext { Provider: ComponentType<{ value: Value; }>; displayName?: string; } /** * This creates a special context for `useContextSelector`. * * @example * import { createContext } from 'use-context-selector'; * * const PersonContext = createContext({ firstName: '', familyName: '' }); */ export declare function createContext(defaultValue: Value): VendorContext; /** * This hook returns context selected value by selector. * * It will only accept context created by `createContext`. * It will trigger re-render if only the selected value is referentially changed. * * The selector should return referentially equal result for same input for better performance. * * @example * import { useContextSelector } from 'use-context-selector'; * * const firstName = useContextSelector(PersonContext, state => state.firstName); */ export declare function useContextSelector(context: VendorContext, selector: (value: Value) => Selected): Selected; /** * This hook returns the entire context value. * Use this instead of React.useContext for consistent behavior. * * @example * import { useContext } from 'use-context-selector'; * * const person = useContext(PersonContext); */ export declare function useContext(context: VendorContext): Value; /** * This hook returns an update function that accepts a thunk function * * Use this for a function that will change a value in * [Concurrent Mode](https://reactjs.org/docs/concurrent-mode-intro.html). * Otherwise, there's no need to use this hook. * * @example * import { useContextUpdate } from 'use-context-selector'; * * const update = useContextUpdate(); * update(() => setState(...)); */ export declare function useContextUpdate(context: VendorContext): (thunk: () => void) => void; /** * This is a Provider component for bridging multiple react roots * * @example * const valueToBridge = useBridgeValue(PersonContext); * return ( * * * {children} * * * ); */ export declare const BridgeProvider: FC<{ context: VendorContext; value: any; }>; /** * This hook return a value for BridgeProvider */ export declare const useBridgeValue: (context: VendorContext) => any;