react-measure icon indicating copy to clipboard operation
react-measure copied to clipboard

Pause Measuring / Only re-render if measurements change

Open danielberndt opened this issue 8 years ago • 2 comments

Hello again!

This is not really an issue, it's rather a request for some feedback.

I'm using react-measure for tooltips and since I'm working on a big app, performance becomes an issue. So I've got the following requirements:

  1. Only start measuring the dimensions of the element if the tooltip needs to be shown
  2. I need to call measure() every x milliseconds, because react-measure doesn't know (for good reasons) if an element's parent caused the element to move. If the call to measure() did not find new dimensions, no re-rendering should happen.

I've created a simple PausableMeasure component here which fulfills my needs for now.

Is this something you feel could benefit react-measure as well or are my requirements too niche?

danielberndt avatar Jul 06 '17 12:07 danielberndt

This sounds pretty interesting! Once I get a chance, I'll look into this.

souporserious avatar Jul 12 '17 16:07 souporserious

I'm pretty new to this, but the fact that the position changes due to parent don't get tracked is a problem for me, too:

  • I need a fixed-position child in order not the influence the layout, so I pass it the bounds from measure.
  • When I tried to use this in a material-ui dialog, it fails as the dialog starts off-screen and gets only moved.

I sort-of solved it using an interval (inspired by the OP), but it'd nice to have such an option <Measure> itself.

Maaartinus avatar Feb 17 '19 18:02 Maaartinus