A minimal reproduction of a memoization bug involving the React Compiler and TanStack Table.
This repo demonstrates that:
- a pagination component imported from another file and using a TanStack Table
Tableinstance 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
pnpm install
pnpm devThen open the app and interact with the table pagination controls.
- Open
src/components/table.tsx - Remove the unreachable return statement at the end of the
Paginationcomponent - Save the file and reload the app if needed
- Observe that the pagination buttons are no longer updating correctly
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
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.