@wordpress/interactivity
Version:
Package that provides a standard and simple way to handle the frontend interactivity of Gutenberg blocks.
89 lines • 3.94 kB
TypeScript
export function useSignalEffect(callback: any): void;
/**
* Accepts a function that contains imperative code which runs whenever any of
* the accessed _reactive_ properties (e.g., values from the global state or the
* context) is modified.
*
* This hook makes the element's scope available so functions like
* `getElement()` and `getContext()` can be used inside the passed callback.
*
* @param {Function} callback The hook callback.
*/
export function useWatch(callback: Function): void;
/**
* Accepts a function that contains imperative code which runs only after the
* element's first render, mainly useful for intialization logic.
*
* This hook makes the element's scope available so functions like
* `getElement()` and `getContext()` can be used inside the passed callback.
*
* @param {Function} callback The hook callback.
*/
export function useInit(callback: Function): void;
/**
* Accepts a function that contains imperative, possibly effectful code. The
* effects run after browser paint, without blocking it.
*
* This hook is equivalent to Preact's `useEffect` and makes the element's scope
* available so functions like `getElement()` and `getContext()` can be used
* inside the passed callback.
*
* @param {Function} callback Imperative function that can return a cleanup
* function.
* @param {any[]} inputs If present, effect will only activate if the
* values in the list change (using `===`).
*/
export function useEffect(callback: Function, inputs: any[]): void;
/**
* Accepts a function that contains imperative, possibly effectful code. Use
* this to read layout from the DOM and synchronously re-render.
*
* This hook is equivalent to Preact's `useLayoutEffect` and makes the element's
* scope available so functions like `getElement()` and `getContext()` can be
* used inside the passed callback.
*
* @param {Function} callback Imperative function that can return a cleanup
* function.
* @param {any[]} inputs If present, effect will only activate if the
* values in the list change (using `===`).
*/
export function useLayoutEffect(callback: Function, inputs: any[]): void;
/**
* Returns a memoized version of the callback that only changes if one of the
* inputs has changed (using `===`).
*
* This hook is equivalent to Preact's `useCallback` and makes the element's
* scope available so functions like `getElement()` and `getContext()` can be
* used inside the passed callback.
*
* @param {Function} callback Imperative function that can return a cleanup
* function.
* @param {any[]} inputs If present, effect will only activate if the
* values in the list change (using `===`).
*/
export function useCallback(callback: Function, inputs: any[]): void;
/**
* Pass a factory function and an array of inputs. `useMemo` will only recompute
* the memoized value when one of the inputs has changed.
*
* This hook is equivalent to Preact's `useMemo` and makes the element's scope
* available so functions like `getElement()` and `getContext()` can be used
* inside the passed factory function.
*
* @param {Function} factory Imperative function that can return a cleanup
* function.
* @param {any[]} inputs If present, effect will only activate if the
* values in the list change (using `===`).
*/
export function useMemo(factory: Function, inputs: any[]): void;
export function withScope(func: Function): Function;
export function createRootFragment(parent: any, replaceNode: any): {
nodeType: number;
parentNode: any;
firstChild: any;
childNodes: any;
insertBefore: (c: any, r: any) => void;
appendChild: (c: any, r: any) => void;
removeChild(c: any): void;
};
//# sourceMappingURL=utils.d.ts.map