Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Placeholder props not working #95

Open
abhishek2524 opened this issue Dec 13, 2021 · 7 comments
Open

Placeholder props not working #95

abhishek2524 opened this issue Dec 13, 2021 · 7 comments

Comments

@abhishek2524
Copy link

abhishek2524 commented Dec 13, 2021

<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!
@virtyaluk
Copy link

Doesn't work for me aswell.

@ThomasFoydel
Copy link

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

@alan-artemest
Copy link

alan-artemest commented Feb 28, 2022

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

@sergiors
Copy link

Anyone solve the problem?

@lagroms
Copy link

lagroms commented Feb 21, 2023

Same here, not working

@retardH
Copy link

retardH commented Dec 6, 2023

Same here, not working till now.

@jotacodestudio
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants