twobin / twobin/react-lazyload

Using a placeholder does not work

Open
#262 2 comments 2 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.9k
Forks
485
PR merge metrics
No merged PRs in 30d

Description

If you pass in a placeholder prop, a ref will never be set so `this.visible` will always be false and LazyLoad will never render children.

See the following render method, where `setRef` is only called if placeholder is not defined: https://github.com/twobin/react-lazyload/blob/7411c5267d7019a418305b382f40220d20bdfba2/src/index.jsx#L294-L300

After some further investigation, it also looks like `ReactDom.findDOMNode` (which was used previously) was never _really_ working for custom placeholder components either--it seems to return a react element which fails the check here as it is not HTML: https://github.com/twobin/react-lazyload/blob/7411c5267d7019a418305b382f40220d20bdfba2/src/index.jsx#L126-L128

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.