This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Question: one vs multiple ResizeObserver(s) performance #59
Comments
The recommended pattern is to use one |
mlaursen
added a commit
to mlaursen/react-md
that referenced
this issue
Nov 11, 2019
Updated the useResizeObserver to use `target` instead of `getTarget`. Stopped using the "shared" ResizeObserver for additionl performance since it lead to memory leaks when components unmounted. For some reason, the `observer.unobserve` doesn't actually stop the handlers from being called if it happened during a React unmount phase? The only way I could prevent the memory leak warnings was to isolate the resize observer to each useEffect and use `observer.disconnect()` which stops *all** (1) observered targets. Using `observer.unobserve` would still cause the memory leak warnings. The downside to this is that it is less performant, but this was probably a pre-mature optimiziation anyways. WICG/resize-observer#59
2 tasks
3 tasks
8 tasks
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
The
ResizeObserver
has anobserve()
method and anunobserve()
method. This seems to encourage having oneResizeObserver
instance and observing and unobserving different elements as needed with logic in the callback to handle each entity. Is there any performance implications of doing this vs instantiating multipleResizeObserver
s for observing different elements or groups of elements?The text was updated successfully, but these errors were encountered: