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

2.6.6 release not compatible with `unmountIfInvisible` prop

Open MattCrouch opened this issue 5 years ago • 10 comments

We are using react-lazyload to only mount a resource-heavy component only when it's visible. The unmountIfInvisible option is ideal for that and previously worked perfectly.

As of the latest release this has broken. It will now intermittently mount and unmount while scrolling.

CodeSandbox demo of issue

While I'm not overly familiar with your codebase, it seems the ref will always point to the one for the placeholder. In 2.6.5, this would refer to either the placeholder or the loaded component depending on which is visible. I think it might be causing it to unmount early as the visibility check then returns false.

MattCrouch avatar Mar 31 '20 17:03 MattCrouch

@MattCrouch thanks for raising this, I will have a look

ameerthehacker avatar Mar 31 '20 17:03 ameerthehacker

I have similar behavior as what @MattCrouch said. It seems to cause unexpected render. And I revert to version 2.6.5 to solve the problem。 Please review this problem ASAP. Thank you very much.

evilucifero avatar Apr 01 '20 04:04 evilucifero

https://codesandbox.io/s/react-lazyload-bug-bf1mx

My problem is when first loading everything seems going well, but any tiny scroll will cause the parent component stops to passing props to children.

evilucifero avatar Apr 01 '20 05:04 evilucifero

@evilucifero thanks for sharing, will looking into it as first thing

ameerthehacker avatar Apr 01 '20 05:04 ameerthehacker

@ameerthehacker Because the impact is relatively large, I rolled back the code to 2.6.7

twobin avatar Apr 01 '20 14:04 twobin

@twobin thank you very much. It seems to work fine right now.

evilucifero avatar Apr 01 '20 14:04 evilucifero

@twobin thanks, will try to find the root of the problem and may be release the fix as beta first as this one seems to be tricky

ameerthehacker avatar Apr 01 '20 17:04 ameerthehacker

@MattCrouch @evilucifero @twobin I have made a fix for this and have release a beta version, the updated codesandbox is here

https://codesandbox.io/s/summer-tree-8z7k2

try it out as

npm i react-lazyload@beta

let me know if everything is working fine, then I will cut a stable release. I will probably create a spectrum channel to discuss similar release plans in the feature

ameerthehacker avatar Apr 02 '20 06:04 ameerthehacker

@ameerthehacker I've tried out the beta version and everything's working great.

Thanks for sorting it out so quickly. Much appreciated!

MattCrouch avatar Apr 02 '20 08:04 MattCrouch

@evilucifero waiting for your response for a stable release

ameerthehacker avatar Apr 03 '20 09:04 ameerthehacker