Safely navigate a null scroll component (offsetHeight of null) #172
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 tothis.scrollComponent
) isnull
. This is odd because it seems as if theref
for the element inrender
no longer exists, but the scroll event is still fired (which is removed incomponentWillUnmount
). We weren't able to get any more information, but by safely navigating theel
(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.