@acrool/react-hooks
Version:
Common javascript utils methods for project development
22 lines (21 loc) • 642 B
TypeScript
interface IUseLazyLoadProps {
enabled?: boolean;
imageUrl?: string;
}
/**
* 攬加載背景圖片
*
* 背景圖片會造成二次加載,因為透過 new Image 加載一次,
* 成功後再給予 style background image 再次加載
* 這部分只能透過瀏覽器的緩存來避免第二次
* @param isLazy
* @param imageUrl
*/
declare const useLazyLoadBackground: ({ enabled, imageUrl, }: IUseLazyLoadProps) => {
imageRef: import('react').RefObject<HTMLDivElement | null>;
_imageUrl: string | undefined;
isPending: boolean;
isFetching: boolean;
isError: boolean;
};
export default useLazyLoadBackground;