Answer the question
In order to leave comments, you need to log in
How to make a stub before loading an image (onLoad)?
Hello. On the page, you need to use 3 different images and make a stub for each image before uploading the image. The method below does not work, namely, the image is not displayed, what is wrong?
const [isLoading, setLoading] = React.useState(false);
const handleOnLoad = () => {
setLoading(true);
}
{isLoading === true ? (<img onLoad={handleOnLoad } src="https://i.5sfer.com/post/postImage/thumb-8ipwnn.jpg"/>) : (<div>*Заглушка*</div>)}
Answer the question
In order to leave comments, you need to log in
You can’t load a picture with such logic either, since you have isLoading false, img is not rendered and onLoad is not called
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question