use-why-rerender
Version:
A React hook to track and debug prop changes in components
34 lines (33 loc) • 999 B
TypeScript
/**
* Configuration options for useWhyRerender hook
*/
interface UseWhyRerenderOptions {
/**
* Enable deep equality checking for object comparisons
* When true, performs recursive comparison of object properties
* @default false
*/
deep?: boolean;
/**
* Enables logging
* When false, logs are not shown in console
* @default true
*/
enabled?: boolean;
/**
* Delay in milliseconds before logging changes
* Useful for reducing lag for components that re-render frequently
* @default 0
*/
debounceMs?: number;
/**
* Custom identifier for the component or hook using useWhyRerender
* Helps identify the source of renders in logs
* @example "MyComponent" | "useMyHook"
*/
caller?: string;
}
type Props = Record<string | symbol, unknown>;
declare function useWhyRerender(props: Props, options?: UseWhyRerenderOptions): void;
export type { UseWhyRerenderOptions };
export { useWhyRerender };