How to check image fully loaded or not? Actually a image coming from API I want to check image height so I'm unable to check image height because image is talking time to load. How to check it in ReactJS?
My code:
export const App = () => {
const [imgHeight, setImgHeight] = useState(0);
var myImage = document.getElementById("myImg");
var isImgLoaded = myImage.complete && myImage.naturalHeight !== 0;
setImgHeight(isImgLoaded ? myImage.getBoundingClientRect().height : "not loaded");
}