souporserious / react-measure

📏 Compute measurements of a React component.
https://souporserious.github.io/react-measure/
MIT License
1.94k stars 109 forks source link

Fix initial onResize delay caused by requestAnimationFrame #135

Closed Jeffrey-Zutt closed 5 years ago

Jeffrey-Zutt commented 5 years ago

Immediately calls the onResize callback on componentDidMount.

The callback is now being called within a requestAnimationFrame to prevent a loop limit exceeded error #133. However, this causes an initial delay and is noticeable in some applications.

souporserious commented 5 years ago

Ah, I've totally run into this before! Thank you for the fix! 🙏 I'm going to add an additional commit after I merge to suppress the initial call from the resize observer. I did something similar in the v3 branch, just never moved those fixes back into v2 😞.

souporserious commented 5 years ago

Published under 2.2.6 🎉. Thanks again!