Optimize useKWindowDimensions
performance
#461
Labels
Component: KResponsiveWindowMixin
good first issue
Self-contained, straightforward, low-complexity
help wanted
Open source contributors welcome
Milestone
Summary
In
useKWindowDimensions
, we readwindow.innerWidth/Height
on eachresize
eventkolibri-design-system/lib/useKWindowDimensions.js
Line 45 in 9ea4bae
kolibri-design-system/lib/useKWindowDimensions.js
Lines 25 to 26 in 9ea4bae
This is not good performance-wise since reading innerWidth/Height causes layout/reflow.
It'd be good to debounce the event handler calls so that
innerWidth/Height
is not read so often.lodash/debounce
is available in this repository for that purpose.References
https://medium.com/@vaibhavar/ui-performance-window-resize-handler-debouncing-2ec5f7432165
The text was updated successfully, but these errors were encountered: