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

Infinite calls to onRowSelect when useDataTable data is empty #160

Open
diegof29 opened this issue Apr 18, 2020 · 1 comment
Open

Infinite calls to onRowSelect when useDataTable data is empty #160

diegof29 opened this issue Apr 18, 2020 · 1 comment

Comments

@diegof29
Copy link

When the data passed to useDataTable is an empty array then the onRowSelect callback gets called in an infinite loop. I think it has something to do with the deps here:

 useEffect(() => {
    if (isSelectable) {
      onRowSelect({
        globalFilter,
        filters,
        filtersByKey: filtersArrayToObject(filters),
        manualFilters,
        manualFiltersByKey: filtersArrayToObject(manualFilters),
        pageIndex,
        pageSize,
        selectedRows: Object.keys(selectedRowIds)
      });
    }
  }, [
    globalFilter,
    filters,
    manualFilters,
    onFetchData,
    pageIndex,
    pageSize,
    selectedRowIds
  ]);
@janus-reith
Copy link

I guess this is not related to the useDataTable hook, but just how the useTable hook from react-table works:
https://react-table.tanstack.com/docs/api/useTable

Both data and column must be memoized, even when they're just an empty array.
But I wonder, if we could just guard against that my memoizing both inside the useDataTable hook, or if this might come with any unwanted side effects.

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