UNPKG

maze-blockly-wrapper

Version:

A Blockly-based maze game wrapper with editable maze generation and programming interface

83 lines (82 loc) 3.75 kB
/** * Hook to create a stable callback reference for class component methods * This is useful when passing methods as props to avoid unnecessary re-renders * @param callback - The callback function to stabilize * @returns A stable callback reference */ export declare function useStableCallback<T extends (...args: unknown[]) => unknown>(callback: T): T; /** * Hook to manage component lifecycle in functional components * Useful for creating wrapper components around class components * @param onMount - Function to call on mount * @param onUnmount - Function to call on unmount */ export declare function useComponentLifecycle(onMount?: () => void, onUnmount?: () => void): void; /** * Hook to create a ref that persists across re-renders * Useful for storing class component instances or DOM elements * @returns A mutable ref object */ export declare function usePersistentRef<T>(initialValue?: T): readonly [import("react").MutableRefObject<T | undefined>, (value: T) => void]; /** * Hook to create a state-like object that persists across re-renders * Useful for storing values that don't trigger re-renders * @param initialValue - Initial value for the persistent state * @returns An object with get and set methods */ export declare function usePersistentState<T>(initialValue: T): { get: () => T; set: (value: T) => void; }; /** * Hook to create a debounced callback * @param callback - The callback to debounce * @param delay - The delay in milliseconds * @returns A debounced version of the callback */ export declare function useDebouncedCallback<T extends (...args: unknown[]) => unknown>(callback: T, delay: number): T; /** * Hook to create a throttled callback * @param callback - The callback to throttle * @param limit - The throttle limit in milliseconds * @returns A throttled version of the callback */ export declare function useThrottledCallback<T extends (...args: unknown[]) => unknown>(callback: T, limit: number): T; /** * Hook to create an interval that can be paused/resumed * @param callback - The callback to execute on each interval * @param delay - The interval delay in milliseconds * @param isActive - Whether the interval should be active */ export declare function useInterval(callback: () => void, delay: number, isActive?: boolean): void; /** * Hook to create a timeout that can be cleared * @param callback - The callback to execute after the timeout * @param delay - The timeout delay in milliseconds * @param isActive - Whether the timeout should be active * @returns A function to clear the timeout */ export declare function useTimeout(callback: () => void, delay: number, isActive?: boolean): (() => void); /** * Hook to create a previous value reference * @param value - The value to track * @returns The previous value */ export declare function usePrevious<T>(value: T): T | undefined; /** * Hook to check if a component is mounted * @returns A boolean indicating if the component is mounted */ export declare function useIsMounted(): boolean; /** * Hook to create a callback that only executes if the component is mounted * @param callback - The callback to wrap * @returns A callback that checks if the component is mounted before executing */ export declare function useMountedCallback<T extends (...args: unknown[]) => unknown>(callback: T): T; /** * Hook to create a state update function that only updates if the component is mounted * @param setState - The setState function from the class component * @returns A setState function that checks if the component is mounted before updating */ export declare function useMountedSetState<T>(setState: React.Dispatch<React.SetStateAction<T>>): React.Dispatch<React.SetStateAction<T>>;