Skip to content

Excessive re-renders when scrolling #352

@christiankaindl

Description

@christiankaindl

Describe the bug

Scrolling a virtualized list seems to cause a 2+ re-renders on every scroll event. In the linked Sandbox, up to 90 re-renders are triggered before any items are added or removed from the virtual list.

Possibly related

Example of react-virtual 2.8, which does not have this problem: https://codesandbox.io/s/react-virtual-2-8-no-re-renders-xlmned

I would love to help debug the issue, but aren't that experienced with monorepo setups yet. Any guidance is appreciated :)

Your minimal, reproducible example

https://codesandbox.io/s/react-virtual-excessive-re-renders-iqtyuf?file=/src/App.js

Steps to reproduce

  1. Scroll the list continuously (e.g. with a trackpad) or use the button "Scroll 1 row"
  2. Observe the console.log's in the console, lots of re-renders are logged

Expected behavior

I would expect to only see re-renders when items are added or removed from the virtualized list.

How often does this bug happen?

Every time

Screenshots or Videos

Screen.Recording.2022-07-29.at.22.33.11.mov

Platform

macOS 12.4

Tested on latest Firefox and Safari

tanstack-virtual version

3.0.0-beta.13

TypeScript version

No response

Additional context

No response

Terms & Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I understand that if my bug cannot be reliable reproduced in a debuggable environment, it will probably not be fixed and this issue may even be closed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions