Skip to content

Commit

Permalink
chore(use-image): remove unneccessary code
Browse files Browse the repository at this point in the history
  • Loading branch information
wingkwong committed Dec 25, 2024
1 parent cfd122d commit 1239c07
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions packages/hooks/use-image/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import type {ImgHTMLAttributes, SyntheticEvent} from "react";

import {useRef, useState, useEffect, MutableRefObject} from "react";
import {useIsHydrated} from "@nextui-org/react-utils";
import {useSafeLayoutEffect} from "@nextui-org/use-safe-layout-effect";

type NativeImageProps = ImgHTMLAttributes<HTMLImageElement>;

Expand Down Expand Up @@ -66,7 +65,7 @@ type ImageEvent = SyntheticEvent<HTMLImageElement, Event>;
*/

export function useImage(props: UseImageProps = {}) {
const {loading, src, srcSet, onLoad, onError, crossOrigin, sizes, ignoreFallback} = props;
const {onLoad, onError, ignoreFallback} = props;

const isHydrated = useIsHydrated();

Expand All @@ -76,18 +75,6 @@ export function useImage(props: UseImageProps = {}) {
isHydrated ? setImageAndGetInitialStatus(props, imageRef) : "pending",
);

useSafeLayoutEffect(() => {
if (!isHydrated) {
return;
}

setStatus(setImageAndGetInitialStatus(props, imageRef));

return () => {
flush();
};
}, [src, crossOrigin, srcSet, sizes, loading]);

useEffect(() => {
if (!imageRef.current) return;
imageRef.current.onload = (event) => {
Expand Down

0 comments on commit 1239c07

Please sign in to comment.