Add useStaticScrollParent #196
Open
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.
Hey there!
Our team is currently using react-list for a project. In the process of doing some performance fixes, I noticed an unusually large chunk of time being spent in scroll events, even with a very simple item render function. Digging deeper through some performance profiling in our app, I found that a large amount of this time was spent calculating styles - specifically,
window.getComputedStyle
(about 70-80% of the frame).Our app has a decently large tree between the list component and the scroll parent, with quite a few styles applied. While we could probably resolve this by using the
scrollParentGetter
and caching the result ourselves, allowing an option to cache the scroll parent in the component saves a lot of duplicated logic, and design-wise didn't seem too far from the norm. In addition, the current implementation could be used in conjunction withscrollParentGetter
, and that function would be invoked only once, with the result cached during the component's lifetime.The option is disabled by default to maintain backwards compatibility.
Let me know if this would be useful, happy to discuss.