question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docs request - additional examples/clarification for using CellMeasurer with a List

See original GitHub issue

With the recent changes in the CellMeasurer API, some of the docs are a little hard to follow. Could you provide additional examples or clarification on how CellMeasurer should be used with a List component?

For my specific situation, I’m trying to understand how to write the rowRenderer function passed into a List. The List docs show the props for the rowRenderer function as:

Responsible for rendering a row. Signature should look like ({ index: number, key: string, style: Object, isScrolling: boolean }): React.PropTypes.node and the returned element must handle index, key and style.

Yet the CellMeasurer docs show an example as:

function rowRenderer ({ index, isScrolling, key, parent, style }) {
  const source // This comes from your list data

  return (
    <CellMeasurer
      cache={cache}
      columnIndex={0}
      key={key}
      parent={parent}
      rowIndex={index}
    >
      {({ measure }) => (
        <img
          onLoad={measure}
          src={source}
        />
      )}
    </CellMeasurer>
  );
}

The rowRenderer function used in the grid example just above on the CellMeasurer docs page has a different set of props passed into the function. The use of ES6 destructuring makes it really hard to follow what properties we have access to in each of these different contexts. Maybe a separate docs page explaining how to use rowRenderer in each of these three contexts could be helpful? Thanks

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
bvaughncommented, Oct 25, 2017

This minimal Twitter app shows a complete integration of AutoSizer + List + CellMeasurer. It’s source code is here. The specific component that ties things together is here. Check that out for a reference, @batamire. 😄

1reaction
rclaicommented, Mar 7, 2017

Sorry didn’t want to flood this thread but you don’t have an example of a CellMeasurer on a List that doesn’t use measure. This example is the only one I’m seeing. The other ones use Grid and Table.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using React Virtualized CellMeasurer with changing data ...
The issue is that the heights are wrong due to the changing order of the messages list so the index's don't have the...
Read more >
Create a Virtualized List with Auto Sizing Cells using react ...
In this lesson we'll use CellMeasurer and CellMeasurerCache to automatically calculate and cache the height of a row.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found