react-with-available-width
react-with-available-width copied to clipboard
Resizing triggering too often
I need to continue exploring how the ResizeObserver should be used optimally. Right now it triggers a few times as part of rendering.
Debounce might help. Also when you are looking into this, make sure to see what it looks like when using this hoc in a bunch of places in different parts of the tree all at the same time--when mounting, updating, and unmounting some things.
Yeah, so far it looks like ResizeObserver has its own debounce built-in. I did add some code to avoid resetting the width when the container element width hasn't changed.
I'll add a more complex example to test out the lifecycle a little better.