Answer the question
In order to leave comments, you need to log in
How to "refresh" an image after the user opened the page offline?
Hello. Let's say a user logged into the panel with the Internet disabled - the onError event fired. Is there any way to reload this image?
const [isLoading1, setLoading1] = React.useState(true);
const [isError1, setError1] = React.useState(false);
const handleOnLoad1 = () => {
setLoading1(false);
setError1(false);
};
const handleOnError1 = () => {
setLoading1(false);
setError1(true);
};
<div>
{isError1 && <div>*Заглушка*</div>}
{isLoading1 && <div>*Загрузка*</div>}
<img
alt="Флаг"
onError={handleOnError1}
src="https://mirpozitiva.ru/uploads/posts/2016-08/medium/1472042492_01.jpg"
height="100"
style={{ display: isError1 || isLoading1 ? "none" : "block" }}
onLoad={handleOnLoad1}
/>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question