File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed
Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -15,14 +15,18 @@ function BlurrableImage({
1515 const [ visible , setVisible ] = React . useState ( ( ) => {
1616 if ( isServer ) return false
1717
18+ // During hydration the element might not be in the DOM yet, so guard
19+ // against null to avoid crashing and fall back to the blurred state.
20+ const el = document . getElementById ( id )
21+ if ( ! ( el instanceof HTMLImageElement ) ) return false
22+
1823 // on the client, it's possible the images has already finished loading.
1924 // we've got the data-evt-onload attribute on the image
2025 // (which our entry.server replaces with simply "onload") which will remove
2126 // the class "opacity-0" from the image once it's loaded. So we'll check
2227 // if the image is already loaded and if so, we know that visible should
2328 // initialize to true.
24- const el = document . getElementById ( id )
25- return el instanceof HTMLImageElement && ! el . classList . contains ( 'opacity-0' )
29+ return ! el . classList . contains ( 'opacity-0' )
2630 } )
2731 const jsImgElRef = React . useRef < HTMLImageElement > ( null )
2832
You can’t perform that action at this time.
0 commit comments