Img onLoad not firing on initial page load when ssr: true
I render a simple image on a route:
When setting ssr: true, the onLoad event doesn't fire, only on further navigation.
When setting ssr: false, the onLoad event fires correctly.
Is it a bug or the expected behavior? How can I get the onLoad event to fire on SSR?
3 Replies
ambitious-aqua•4w ago
Event Handlers like the onLoad should not fire in SSR i believe
absent-sapphireOP•4w ago
Is it because onLoad events are attached by React during hydration, and an image may have already loaded during that timeframe? So I should leverage
complete
props to detect if it has loaded in a useEffectcorrect-apricot•4w ago
exactly, i just use a layout effect in the image component to check the reference to see if it has loaded