react-lazyload icon indicating copy to clipboard operation
react-lazyload copied to clipboard

Add compatibility with react-snapshot

Open LinusGeffarth opened this issue 5 years ago • 5 comments
trafficstars

I added react-lazyload (I'm impressed by the ease of use!) and have tried it out on my site. Since I'm client-rendering, I use react-snapshot to generate html-only versions of my site. Unfortunately, the images don't appear in the snapshot pages.

Is there a way to add compatibility for this use-case? Such as disabling the laziness when snapshotting?
Thanks!

LinusGeffarth avatar Apr 30 '20 23:04 LinusGeffarth

@LinusGeffarth I think you can do that through environment variables supported by react and use it to turn on or off the lazy loading

ameerthehacker avatar May 01 '20 06:05 ameerthehacker

Thanks. But how world I turn it off at run time?

LinusGeffarth avatar May 01 '20 07:05 LinusGeffarth

@LinusGeffarth you can set the forceVisible prop which will kind of turn lazy loading off

ameerthehacker avatar May 01 '20 09:05 ameerthehacker

How would I do that? I don't have an extra component for images at the moment. I just do:

<LazyLoad>
  <img src="" />
</LazyLoad>

So how do I do that?

LinusGeffarth avatar May 01 '20 18:05 LinusGeffarth

https://github.com/twobin/react-lazyload#forcevisible check the above link, you can call forceVisible method

ameerthehacker avatar May 03 '20 06:05 ameerthehacker