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

Pause Measuring / Only re-render if measurements change #68

Open
danielberndt opened this issue Jul 6, 2017 · 2 comments
Open

Pause Measuring / Only re-render if measurements change #68

danielberndt opened this issue Jul 6, 2017 · 2 comments

Comments

@danielberndt
Copy link
Contributor

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?

@souporserious
Copy link
Owner

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

@Maaartinus
Copy link

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.

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

No branches or pull requests

3 participants