react-lazy-load-image-component icon indicating copy to clipboard operation
react-lazy-load-image-component copied to clipboard

Placeholder props not working

Open abhishek2524 opened this issue 2 years ago • 7 comments

<LazyLoadImage
        src="https://cdn.pixabay.com/photo/2016/04/04/14/12/monitor-1307227_960_720.jpg"
        key={1}
        alt={`simple`}
        // effect="opacity"
        // effect="blur"
        placeholderSrc={<div>Loading......</div>}
        placeholder={<div>Wait......</div>}
      />
      Please help!

abhishek2524 avatar Dec 13 '21 07:12 abhishek2524

Doesn't work for me aswell.

virtyaluk avatar Jan 07 '22 10:01 virtyaluk

I'm getting the same issue, though I'm passing a component for the placeholder and a string (a url) for the placeholderSrc, neither show up. Currently I'm conditionally rendering a loading spinner, and then changing a state value with afterLoad and then using that state value to conditionally hide the loadingspinner, but it is hacky and somewhat difficult to style

ThomasFoydel avatar Jan 08 '22 02:01 ThomasFoydel

The issue here is that the final img content - in case of placeholder prop specified - replaces the placeholder once intersected, then you need waiting for the img loading time. That would not the way this library should working: the correct way is the one implemented via placeholderSrc

alan-artemest avatar Feb 28 '22 14:02 alan-artemest

Anyone solve the problem?

sergiors avatar Aug 24 '22 00:08 sergiors

Same here, not working

lagroms avatar Feb 21 '23 13:02 lagroms

Same here, not working till now.

retardH avatar Dec 06 '23 04:12 retardH

Thanks for addressing this matter. While it looks like several of you are affected by this, it's still not clear to us what the exact issue is. Any help clarifying the problem would be greatly appreciated.

I tested the code provided by @abhishek2524, and it functions as anticipated on my end. Please note that the placeholder is only displayed until the image loads. You might want to take a look at "All images are loaded at once" (https://github.com/Aljullu/react-lazy-load-image-component?tab=readme-ov-file#all-images-are-being-loaded-at-once) in our Common errors docs, as this is a common source of confusion: if at some point the placeholder of LazyLoadImage is in the viewport, it will switch to the element and the placeholder won't be shown anymore.

jotacodestudio avatar May 05 '24 21:05 jotacodestudio