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

React Measure is only called for first time #149

Open
emonno13 opened this issue Aug 29, 2021 · 1 comment
Open

React Measure is only called for first time #149

emonno13 opened this issue Aug 29, 2021 · 1 comment

Comments

@emonno13
Copy link

I have an issue with the height of the scroll change.

Step 01: I load the page.

  • Topbar is shown
  • Height: 426
  • Show scroll
    image

Step 02: Click a button to hide the top bar.

  • React Measure work
  • Height: 491
  • Show scroll
    image

Step 03: Click a button to show the top bar again.

  • React Measure does not work
  • Height: 491 ( must be 426 )
  • Scroll is clipped
    image

I don't know why React-measure did not trigger when the top bar is shown again.

Here is my code:

image

@souporserious
Copy link
Owner

Hm I'm not sure why the ResizeObserver wouldn't be picking this up 🤨 maybe due to children being virtualized. I'm pretty busy right now so I won't be able to look into the library itself for a bit, but I think you should be able to grab a ref to the Measure component and call the internal measure method yourself to update the dimensions:

function App() {
  const ref = React.useRef()
  return (
    <div>
      <button onClick={() => ref.current.measure()}>
        Measure programmatically
      </button>
      <Measure ref={ref}>...</Measure>
    </div>
  )
}

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

No branches or pull requests

2 participants