twobin / twobin/react-lazyload

2.6.6 release not compatible with `unmountIfInvisible` prop

Open
#296 10 comments 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.9k
Forks
485
PR merge metrics
No merged PRs in 30d

Description

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](https://codesandbox.io/s/react-lazyload-bug-ig94t)

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`.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.