Re-render issue: Masonry Grid implementation in Next.js
Hello,
I've been facing this issue for a while now, I have a masonry grid that renders images from an external source, and when the image source is broken, I set the source to a default image that shows the image is broken.
Now every time I scroll, the image starts loading again (because I have a shimmer effect flash for a sec), and it doesn't have to be a big scroll, it could be as little as little as a few pixels (~10px).
On Firefox - All the images reload
On Chrome (or Chromium based browsers) - Just the broken images load again
Here is the code to the customized
next/image
component I'm using below;
Can anyone help me understand what might be going on?
Thanks2 Replies
national-gold•10mo ago
hmm hard to say, but if the image are loaded again then it would mean that CustomNextImage is unmounted and mounted, i would suggest to start with that.
fascinating-indigoOP•10mo ago
Yeah! Same thought that I had, I'm trying to see what could be causing that. I'll let you know what I find out
Turns out it was an issue with the key prop on the parent component 😅