souporserious/react-measure

How detect offset?

Opened this issue · 3 comments

eseQ commented

Hello.
I use react-measure to detect dimensions and offset changes in my case.
Main idea: Have a visible list and list of hidden items;
But I have no way to track offset changes.
I created demo: https://codesandbox.io/s/modest-list-omkl0
I have a list like this: before
And if add some element: after
No one after the new element does not touch onResize callback. Yeah, dimensions stay without changes but bounds (offsets) have been changed.
Any ideas?

Weird! I'm not sure why it's not calling onResize properly 🤔 Everything looks fine in your code. I noticed you are using hooks. You might have better luck with something like use-measure library. I'm hoping to release a hooks version soon that might help here. I'll dig deeper when I get some time. Thanks for filing an issue and putting together a code sample! 🙏

eseQ commented

@souporserious thanks for the answer. Use measure-hook it`s a clever idea. Let`s test it!
https://codesandbox.io/s/modest-list-56t7e
Good news - now we know about the change position.
But we have strange behavior - equivalents x values for all items. And the right value obviously.

demo

eseQ commented

@cvpcasada can you help me? Maybe I use use-measure wrong?