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.

InfiniteLoader and Table

See original GitHub issue

I’m hitting a wall over here, I think it might be a bug. (Using version 9.13.0, I’ll try this updating a bit later, but the changelog doesn’t make me think it’s fixed?)

So I have a component that’s like this (omitting boilerplate):

rowCount = this.rowCount()

return (
  <InfiniteLoader
    isRowLoaded={this._isRowLoaded}
    loadMoreRows={this._loadMoreRows}
    rowCount={rowCount}
  >
    <Table
      rowGetter={rowGetter}
      rowRenderer={rowRenderer}
      rowCount={rowCount}
    >
      {columns.map(column => <Column {...column} />)}
    </Table>
  </InfiniteLoader>
)

columns is an array of objects with Column’s properties (label, dataKey, width)

The problem arises with InfiniteLoader:

  • The component mounts, data isn’t fetched yet, so data = [], data.length = 0
  • rowCount is going to be 1(!!!), because there are more available items to be fetched.
  • This row is out of the available data: it is not loaded yet, so I would like to render a LoadingRow component for this one row.

Using List instead of Table this is rather simple, in the rowRenderer method check if that row is loaded using isRowLoaded and render accordingly. But I haven’t been able to do the same using Table, because before rowRenderer gets called, I get an Uncaught TypeError in defaultCellDataGetter here:

export default function defaultCellDataGetter(_ref) {
  var dataKey = _ref.dataKey,
      rowData = _ref.rowData;

  if (typeof rowData.get === 'function') {   <<<=== HERE
    return rowData.get(dataKey);
  } else {
    return rowData[dataKey];
  }
}

Because rowData is undefined, and that’s because the rowGetter function is like this rowGetter = (list, index) => list[index]. So before being able to check in rowRenderer whether the row is loaded or not, it crashes in defaultCellDataGetter, because rowData is undefined.

I could get around this just adding cellDataGetter to each column, but it doesn’t look right.

That’s all I think. I don’t know if I’m getting this right (and it is a bug), or if there is another way this should be done.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

3reactions
christopher-franciscocommented, Mar 14, 2018

@bvaughn Can we just add to the Table docs that rowGetter should not return null nor undefined, but instead an empty object {}?

It took me a while to figure out this was the problem, and I think it might help other devs 😃

1reaction
kgregorycommented, Mar 15, 2018

@cristianfraser maybe we should default rowData to an empty object in defaultCellDataGetter?

See any issues with this @bvaughn?

Read more comments on GitHub >

github_iconTop Results From Across the Web

react virtualized infinite loader autosize table example
1. const { Table, Column, AutoSizer, InfiniteLoader } = ReactVirtualized ; 2. const generateRandomItem = (idx) => ({ ; 3. id: idx, ;...
Read more >
Using React-Virtualized InfiniteLoader, Autosizer, and ...
Create a table component that we can plug in all over our application, passing in variable columns/data retrieved from various endpoints.
Read more >
react-virtualized/InfiniteLoader.md at master
A component that manages just-in-time fetching of data as a user scrolls up or down in a list. Note that this component is...
Read more >
react-window-infinite-loader examples
Learn how to use react-window-infinite-loader by viewing and forking example apps that make use of react-window-infinite-loader on CodeSandbox.
Read more >
javascript - Building a responsive infinite scroll table with ...
What I want to achieve is a HTML like table that resizes based on the browser window's width, grows row heights vertically as...
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