Last active
November 8, 2021 15:22
-
-
Save St2r/8486b61aec5b786d4c6b65a8b6189819 to your computer and use it in GitHub Desktop.
make DOM event handled after React hydrate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const handleLoad = ( | |
e: SyntheticEvent<HTMLImageElement> | |
) => { | |
console.log('onload'); | |
}; | |
return ( | |
<img | |
ref={(input: HTMLImageElement | null) => { | |
if (input) { | |
(input.onload as any) = handleLoad; | |
imgRef.current = input; | |
} | |
}} | |
src={'example.webp'} | |
/> | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment