Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reuse single instance of ResizeObserver in Flyouts. #326

Open
mareksed opened this issue Sep 28, 2024 · 0 comments
Open

Reuse single instance of ResizeObserver in Flyouts. #326

mareksed opened this issue Sep 28, 2024 · 0 comments

Comments

@mareksed
Copy link

Is your feature request related to a problem? Please describe.
Our use case in which we are using reshaped is performance sensitive.
My knowledge about ResizeObservers is that less instances we have the better the perf is,
please follow this thread WICG/resize-observer#59 (comment)

I found this snippet in sources of useFlyout.

	React.useEffect(() => {
		const resizeObserver = new ResizeObserver(() => updatePosition({ sync: true }));

		resizeObserver.observe(document.body);
		if (triggerElRef.current) resizeObserver.observe(triggerElRef.current);

		return () => resizeObserver.disconnect();
	}, [updatePosition, triggerElRef]);

useFlyout is a hook that is composed a lot, and is at the core of every Tooltip, so it will be used a lot in an UI and will create, new ResizeObserver and every one of those will be observing document body.

Describe the solution you'd like
Reuse single instance of ResizeObserver

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 3.2.0
Development

No branches or pull requests

1 participant