-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
ResizeGroup: Improve perf by making sure resize data state change is batched. #15701
Conversation
a5c5ad6
to
9f2e9ac
Compare
This pull request is automatically built and testable in CodeSandbox. To see build info of the built libraries, click here or the icon next to each commit SHA. Latest deployment of this branch, based on commit 749b825:
|
Perf AnalysisNo significant results to display. All results
Perf Analysis (Fluent)Perf comparison
Perf tests with no regressions
|
Asset size changesUnable to find bundle size details for Baseline commit: 0fe2bfa Possible causes
Recommendations
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice fix!
🎉 Handy links: |
…batched. (microsoft#15701) * fix resize group perf * Change files * change to useReducer * add comments
Pull request checklist
$ yarn change
Description of changes
React
is not batching the state changes when states are set in callbacks likesetTimeout
orrequestAnimationFrame
. See issue: facebook/react#14259In
ResizeGroup
, we callupdateResizeState
fromrequestAnimationFrame
callback.updateResizeState
call differentuseState
setters which causes un-batched re-renders. The fix here is to groupresize
data into a single state inuseResizeData
hook.Also noticed couple places where we should memoize the callbacks returned from
updateResizeState
.Focus areas to test
perf-test
results for components which usesResizeGroup
:Breadcrumb
,CommandBar