Replies: 1 comment
-
Turns out the issues I was facing were more or less my fault, I tested it on a few different pages seems to work fine. can be tested here : #774 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The whole app re-renders when the window is resized this can clearly be seen in the react dev tools or by monitoring the cpu usage while resizing the window.
I've made a sandbox here that shows the problem and a few solutions
Add a debounce to window resize event so it doesn't trigger so many renders.
Pros: [Easy, Doesn't break stuff]
Cons: [Kind of a hack]
Optimize useIsMobile and similar to only re-render when their value has changed, this leads to far less rendering.
Pros: [Excellent performance]
cons: [Breaks stuff]
To use the sandbox just resize the virtual window and see the render counter go up, because it's code sandbox the number of re-renders are much higher than you would see IRL, but the ratio of renders between the 3 experiments should remain the same.
Beta Was this translation helpful? Give feedback.
All reactions