react / react/react

Bug: performance deteriorates when using ReactDOM.createRoot instead of ReactDom.render for virtual-table.

Open
#27,524 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Type: Needs Investigation
Dominant language
JavaScript
Stars
251k
Forks
51.4k
Avg merge
2d 4h
Merged PRs (30d)
53

Description

While experimenting with react-window, I encountered a performance disparity in my project compared to the smooth user experience demonstrated in the react-window documentation examples. Even after building for production, I noticed white flashes when scrolling quickly in my project, whereas the documentation's examples remained consistently smooth.

After conducting several experiments, I successfully identified the root cause: the performance significantly deteriorates when using ReactDOM.createRoot compared to the now deprecated ReactDOM.render.

Here is a video to illustrate the issue:
https://github.com/facebook/react/assets/7544804/0be9ba6f-47e8-4d61-bb6c-e8fef0787776

This issue is not exclusive to react-window; in fact, I first encountered it while developing a toy version of it using function components and hooks (react-window itself is currently implemented using class components).

React version:
Tried with react/react-dom 18.2.0 and react/react-dom 18.3.0-canary-09fbee89d-20231013

Link to code example:
Here are two CodeSandbox examples of the same scenario with only one distinction:

Additionally, I've created two CodeSandbox using my own simplified version of a virtual table, the performance issue is also noticeable in this scenario:

The current behavior

The performance appears to be worse when using ReactDom.createRoot compared to ReactDom.render

The expected behavior

Using ReactDom.createRoot should give the same performance or better performance than ReactDom.render

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox pairs, comparing ReactDOM.render and ReactDOM.createRoot in the virtual-table and simplified examples. Reproduce the scrolling behavior with React 18.2.0 and the listed 18.3.0 canary, including a production build. Done means createRoot no longer shows the reported performance disparity or white flashes relative to render.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.