qwik
qwik copied to clipboard
[📖] onLoad$ img cookbook
Suggestion
document a better way to detect onLoad for images https://github.com/QwikDev/qwik/issues/4481
const imgRef = useSignal<HTMLImageElement>();
useVisibleTask$(()=> {
imgRef.value!.decode().then(() => {
console.log('loaded and ready!');
});
});
// other logic etc
return (
<section>
<img ref=[imgRef} srf="some-source.png" height={200} width={200} />
</section>
);