File tree 2 files changed +12
-3
lines changed
packages/hooks/use-image/src
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ " @nextui-org/use-image " : patch
3
+ ---
4
+
5
+ set status after hydrated
Original file line number Diff line number Diff line change @@ -71,9 +71,7 @@ export function useImage(props: UseImageProps = {}) {
71
71
72
72
const imageRef = useRef < HTMLImageElement | null > ( isHydrated ? new Image ( ) : null ) ;
73
73
74
- const [ status , setStatus ] = useState < Status > ( ( ) =>
75
- isHydrated ? setImageAndGetInitialStatus ( props , imageRef ) : "pending" ,
76
- ) ;
74
+ const [ status , setStatus ] = useState < Status > ( "pending" ) ;
77
75
78
76
useEffect ( ( ) => {
79
77
if ( ! imageRef . current ) return ;
@@ -97,6 +95,12 @@ export function useImage(props: UseImageProps = {}) {
97
95
}
98
96
} ;
99
97
98
+ useEffect ( ( ) => {
99
+ if ( isHydrated ) {
100
+ setStatus ( setImageAndGetInitialStatus ( props , imageRef ) ) ;
101
+ }
102
+ } , [ isHydrated ] ) ;
103
+
100
104
/**
101
105
* If user opts out of the fallback/placeholder
102
106
* logic, let's just return 'loaded'
You can’t perform that action at this time.
0 commit comments