measureRef gives wrong size at first render
See original GitHub issueHi,
I am trying to use react-virtual to render a dynamic-height list. When I pass measureRef to my list item wrapper like <div ref={measureRef}><ListItem /></div> it calculates the height of each visible list item as 48px. But this value is not correct. Calculation becomes correct when I start scrolling for the first time to trigger a change on visible portion of the list.
When I pass the ref using a arrow function like <div ref={element => measureRef(element)}><ListItem /></div> it calculates and renders correctly.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:9
- Comments:8 (2 by maintainers)
Top Results From Across the Web
measureRef gives wrong size at first render · Issue #85 - GitHub
Hi, I am trying to use react-virtual to render a dynamic-height list. When I pass measureRef to my list item wrapper like it...
Read more >How can I respond to the width of an auto-sized DOM element ...
We're doing all of our 3rd-party SVG rendering in shouldComponentUpdate, but you cannot set state or properties on yourself or other child components...
Read more >Use ref callbacks to measure React component size
You can use ref callbacks to measure the rendered size of React components, did you know? It's a neat little trick. Here's how...
Read more >API Reference | React Virtual - TanStack
Optional; Defines initial rect size of list. Can be used for server-side rendering. useObserver: Function(parentRef: React.useRef(DOMElement), initialRect?:
Read more >How to Get The Size of a React Native View Dynamically
React Native provides a Dimensions API that can be used to get the width ... the first render call, but the whole point...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@sarioglu - this issue advice saved me. I was having trouble with lists of a certain size not displaying correctly until i scrolled as well. This arrow function fix solved the problem!