shadcn-ui / ui

Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
https://ui.shadcn.com
MIT License
63.67k stars 3.6k forks source link

[bug]: data-table pagination breaks with React Compiler #3905

Open biohackerellie opened 1 month ago

biohackerellie commented 1 month ago

Describe the bug

With the experimental react compiler in Next Canary, the table will receive all the data but the pagination no longer functions, clicking the "next" button with a default example does not move to the next page.

Affected component/components

Data-Table

How to reproduce

Using the base example

import { Button } from "@/components/ui/button"

export function DataTable<TData, TValue>({
  columns,
  data,
}: DataTableProps<TData, TValue>) {
  const table = useReactTable({
    data,
    columns,
    getCoreRowModel: getCoreRowModel(),
    getPaginationRowModel: getPaginationRowModel(),
  })

  return (
    <div>
      <div className="rounded-md border">
        <Table>
          { // .... }
        </Table>
      </div>
      <div className="flex items-center justify-end space-x-2 py-4">
        <Button
          variant="outline"
          size="sm"
          onClick={() => table.previousPage()}
          disabled={!table.getCanPreviousPage()}
        >
          Previous
        </Button>
        <Button
          variant="outline"
          size="sm"
          onClick={() => table.nextPage()}
          disabled={!table.getCanNextPage()}
        >
          Next
        </Button>
      </div>
    </div>

nothing happens when clicking next

Mainly bringing awareness to this and can simply opt out of the compiler for this component for now

Codesandbox/StackBlitz link

No response

Logs

No response

System Info

windows 11, wsl ubuntu 22.04. Next.canary.7 react 19.0.0-rc, babel-plugin-react-compiler 0.0.0-experimental, tanstack/react-table 8.17.3

Before submitting

mickdewald commented 2 weeks ago

It's not the fault from shadcn, but from @tanstack/react-table. It does not support it currently. https://tanstack.com/table/latest/docs/installation

NOTE: Even though the react adapter works with React 19, it may not work with the new React Compiler that's coming out along-side React 19. This may be fixed in future TanStack Table updates.

I have the same errors. Also filtering and checkbox clicks are not working with activated react compiler.