Open Floriferous opened 3 years ago
I have the same issue too.
i thought this worked properly, but it seems broken in the current version
For me width
& height
are inverted.
Did you guys find the last stable version for useMeasure
?
I have the same problem, top
and left
are always 0
Forked the codesandbox above and copy useMeasure
to inspect the error:
https://codesandbox.io/s/little-dream-fbtp6?file=/src/useMeasure.js:609-655
the contectRect has difetent info than target.getBoundingClientRect
in the observed target
Hey @tomasdisk
You can take a look at react-hookz, a bunch of guys from here has created it since react-use
seems to be dead at this point.
They have a useMesure hook.
@fcisio Thanks for the info! I'll check it 😄
Upping this thread so it won't become stale.
Facing same issue, any chance the PR would be merged?
I have the same issue too. top and left are always 0
same issue here in 2023
I'm also having the same issue 2024
What is the current behavior?
I'm not sure if I understand the
useMeasure
correctly, but the goal is for it to return theboundingClientRect
of the element right?If that is the case, then the
x
value, and probably others, seem to be wrong, as it's always 0 on my end.Steps to reproduce it and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have extra dependencies other than
react-use
. Paste the link to your JSFiddle or CodeSandbox example below: Here's a very simple reproduction: https://codesandbox.io/s/broken-browser-lh313?file=/src/App.jsI compared it with the DOM API on the same node so you can see what I expect.
What is the expected behavior? I expect the result of
useMeasure
left and X to match the ones from the DOM.A little about versions:
react-use
: latest