TanStack / table

🤖 Headless UI for building powerful tables & datagrids for TS/JS - React-Table, Vue-Table, Solid-Table, Svelte-Table
https://tanstack.com/table
MIT License
25.23k stars 3.08k forks source link

Infinite loop caused by combining virtual scroll and grouping #4929

Open art0rz opened 1 year ago

art0rz commented 1 year ago

Describe the bug

I'm trying to combine virtual scrolling and row grouping, but it is causing an infinite loop.

Here is an example. Uncomment line 75 in main.tsx and you will see endless console messages and the browser tab will freeze.

Is there another way I should be combining these two features, or is this a bug? I couldn't find an example online that combines these two features.

Your minimal, reproducible example

https://codesandbox.io/p/sandbox/elastic-mendeleev-3nqqhg?embed=1&file=%2Fsrc%2Fmain.tsx%3A75%2C32

Steps to reproduce

  1. Open https://codesandbox.io/p/sandbox/elastic-mendeleev-3nqqhg?embed=1&file=%2Fsrc%2Fmain.tsx%3A75%2C32
  2. Uncomment line 75

Expected behavior

Infinite loop does not occur

How often does this bug happen?

Every time

Screenshots or Videos

https://github.com/TanStack/table/assets/358661/865d1a1d-e995-4c94-a937-8419ca8b293e

Platform

Chrome, Arch Linux x64

react-table version

8.9.2

TypeScript version

No response

Additional context

react-virtual v2.10.4

Terms & Code of Conduct

focux commented 1 year ago

I just came to report this, I'm experiencing this same problem. I'm using react-table v8.7.4 and react-virtual v2.10.4

sonchau commented 1 year ago

I am having the same issue, using the following versions "react-virtual": "^2.10.4", "react-table": "^8.5.15",

Zeddox commented 2 months ago

I was having this same issue but no virtualizer. It came down to making sure the grouping state value was a stable reference (either a ref/memo or outside of the component function) and then the infinite loop stopped.