Open harryhanYuhao opened 3 months ago
even iam facing the same issue
I have the same issue, it appears when using a cell render for me, that I get hydration issues. Even something as simple as
export const columns: ColumnDef<Payment>[] = [
{
accessorKey: 'status',
header: 'Status',
cell: ({ cell }) => {
return <TableCell>asdf</TableCell>
},
},
{
accessorKey: 'email',
header: 'Email',
},
{
accessorKey: 'amount',
header: 'Amount',
},
]
throws the error. Update: I notice that it happens with the TableCell being rendered. If we try a different component, then there is no problem, such as:
export const columns: ColumnDef<Payment>[] = [
{
accessorKey: 'status',
header: 'Status',
},
{
accessorKey: 'email',
header: 'Email',
},
{
accessorKey: 'amount',
header: () => <div className="text-right">Amount</div>,
cell: ({ row }) => {
const amount = parseFloat(row.getValue('amount'))
const formatted = new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD',
}).format(amount)
return <div className="text-right font-medium">{formatted}</div>
},
},
{
id: 'actions',
cell: ({ row }) => {
const payment = row.original
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button variant="ghost" className="h-8 w-8 p-0">
<span className="sr-only">Open menu</span>
<MoreHorizontal className="h-4 w-4" />
</Button>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>Actions</DropdownMenuLabel>
<DropdownMenuItem
onClick={() => navigator.clipboard.writeText(payment.id)}
>
Copy payment ID
</DropdownMenuItem>
<DropdownMenuSeparator />
<DropdownMenuItem>View customer</DropdownMenuItem>
<DropdownMenuItem>View payment details</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
)
},
},
]
I have the same issue. I can remove the error by methods 1 or 2 from https://nextjs.org/docs/messages/react-hydration-error.
However any changes to columns.tsx do not appear in the rendered page. See my stack exchange question for more detail. https://stackoverflow.com/questions/78695847/nextjs-shadhui-datatable-persistent-cache
I hope someone can help as progress on my project has come to a complete halt in the last 24 hours.
Describe the bug
Data table demo causes hydration error with nextjs. I use exactly the same code that is the first example shown here.
Affected component/components
Input
How to reproduce
Use the example data table demo as a react component and hydration error will be shown. It seems like if the
<Input>
components is commented the hydration error will stop.It also seems like that if I use
to ensure the component is only rendered in the client side there will also be no errors.
This error is reproduced in codesandbox.
Codesandbox/StackBlitz link
https://codesandbox.io/p/live/aafbf382-588e-4f61-8fca-9254ced395b9
Logs
No response
System Info