johannschopplich / unlazy

🪧 Universal lazy loading library for placeholder images leveraging native browser APIs
https://unlazy.byjohann.dev
MIT License
760 stars 11 forks source link

Missing reactivity for `src` prop in `UnLazyImage` #52

Open talaxasy opened 5 months ago

talaxasy commented 5 months ago

Reproduction

Reproduction link: link

Insert any image from the ones provided, for example Ivan Grozny, and click on the "Update Image" button. The image is expected to change. In fact, what happens is that the image remains the same

Describe the bug

After reactively changing the image URL, the UnLazyImage component does not render the new value inside the src prop.

Additional context

image

Logs

No response

felixranesberger commented 5 months ago

I looked into the source code and I think this is not implemented at the moment. You can probably use :key="currentImageUrl" to force a re-render of the whole component and its lazy loading functionality when the value changes.

johannschopplich commented 5 months ago

Great catch! Yeah, the reactiveness is missing at the moment… PR welcome!

talaxasy commented 5 months ago

Yes, I already use :key for rerendering, can we consider the issue closed?

johannschopplich commented 5 months ago

Please leave it open. Technically speaking, it's a bug and everyone rightfully can expect props to be reactive. 😌