Skip to content

DerTimonius/react-compiler-tanstack-table-repro

Repository files navigation

React Compiler + TanStack Table Memoization Repro

A minimal reproduction of a memoization bug involving the React Compiler and TanStack Table.

What happens

This repo demonstrates that:

  • a pagination component imported from another file and using a TanStack Table Table instance can get stuck with stale values
  • adding an unreachable return that references table changes the behavior
  • adding "use no memo" to the pagination component also fixes the issue

Repro steps

pnpm install
pnpm dev

Then open the app and interact with the table pagination controls.

How to reproduce the bug

  1. Open src/components/table.tsx
  2. Remove the unreachable return statement at the end of the Pagination component
  3. Save the file and reload the app if needed
  4. Observe that the pagination buttons are no longer updating correctly

Workarounds

The issue can be avoided by either:

  • adding "use no memo" to the top of the Pagination component file
  • keeping the unreachable return that references table

Notes

This appears to be related to the React Compiler's handling of TanStack Table's mutable Table instance and derived method calls such as:

  • table.getCanNextPage()
  • table.getCanPreviousPage()
  • table.getPageCount()
  • table.getState()

Extracting the getter values into variables does not solve the issue.

About

Repro for https://github.com/facebook/react/issues/36331

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors