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

useElementSize doesn't work when used on <svg> element #253

Closed
callumacrae opened this issue Nov 16, 2022 · 1 comment
Closed

useElementSize doesn't work when used on <svg> element #253

callumacrae opened this issue Nov 16, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@callumacrae
Copy link

https://chromestatus.com/feature/5724912467574784

SVGElement.offsetWidth doesn't exist anymore, so useElementSize() always returns 0.

I've fixed this locally by replacing offsetWidth with getBoundingClientRect(), but wanted to discuss that before sending a PR as it's a breaking change per this answer on Stack Overflow.

One way around the breaking change would be to check whether the element is an HTML element or SVG element before calling getBoundingClientRect() - would that be good for you?

@juliencrn juliencrn added the bug Something isn't working label Jan 7, 2024
@juliencrn
Copy link
Owner

Hi, useElementSize has been deprecated and should be replaced by useResizeObserver. It doesn't support svg, but you can wrap this svg in a div to have the expected behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants