Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safely navigate a null scroll component (offsetHeight of null) #172

Conversation

skovy
Copy link

@skovy skovy commented Aug 22, 2018

Issue: https://github.com/CassetteRocks/react-infinite-scroller/issues/147

We've been running into these errors:

  • Cannot read property 'offsetHeight' of null
  • null is not an object (evaluating 'el.offsetHeight')

The problem appears to be that el (which is equivalent to this.scrollComponent) is null. This is odd because it seems as if the ref for the element in render no longer exists, but the scroll event is still fired (which is removed in componentWillUnmount). We weren't able to get any more information, but by safely navigating the el (this.srollComponent) it appeared to fix the issue without any user facing impact. Based on the linked issue, it seems others are also running into this problem?

A test case was added to simulate this scenario, but required reaching into the internals. Let me know if it's better to remove it altogether?

This is data for this error over several days, measured in thousands. We forked this repository and tried this patch for a week and this seems to resolve this specific issue.
example

@danbovey danbovey merged commit 4d9f594 into danbovey:master Sep 14, 2018
@danbovey
Copy link
Owner

Thanks for the great work! Release in 1.2.1

@skovy skovy deleted the skovy/safely-navigate-null-scroll-component branch September 14, 2018 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants