@supunlakmal/hooks
Version:
A collection of reusable React hooks
19 lines (18 loc) • 683 B
TypeScript
interface ImageOnLoadResult {
/** Indicates if the image is currently loading. */
isLoading: boolean;
/** Any error that occurred during loading. */
error: Event | string | null;
/** The natural width of the image once loaded. */
naturalWidth: number | null;
/** The natural height of the image once loaded. */
naturalHeight: number | null;
}
/**
* Custom hook to track the loading status and dimensions of an image.
*
* @param src The source URL of the image to load.
* @returns An object containing the loading state, error, and image dimensions.
*/
export declare function useImageOnLoad(src?: string): Readonly<ImageOnLoadResult>;
export {};