twobin / twobin/react-lazyload

Fall back to using `window`, when the querySelector for scrollContainer returns null

Open
#259 1 comment 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
5.9k
Forks
485
PR merge metrics
No merged PRs in 30d

Description

I have a problem in my app where when unloading a page a loading another one I pass the ID of my own `scrollContainer` but that scroll container element only exists in the unloading page, but not in the page that is currently loading.
Problem is that react-lazy load executes a `scrollport.document.querySelector(scrollContainer)` which returns `null`, hence crashes.
My suggestion is to default back to the `window` element if the `querySelector` returns `null`

This line:
`scrollport = scrollport.document.querySelector(scrollContainer);`
would become this:
`scrollport = scrollport.document.querySelector(scrollContainer) || window;`

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.