nextui icon indicating copy to clipboard operation
nextui copied to clipboard

[BUG] - Hydration Error with Table selectionMode = multiple

Open TwoWheelDev opened this issue 1 year ago • 16 comments

NextUI Version

2.6.8

Describe the bug

Using the example code from https://nextui.org/docs/components/table#use-case-example, causes a hydration error.

I have added the 'use client' as required (since the page uses useState etc).

Digging into it, if I change selectionMode="multiple" to selectionMode="single" the hydration error disappars, so the error appears to be with the column that is added to allow multiple selections

Your Example Website or App

https://codesandbox.io/p/devbox/elastic-tu-vydmx3?workspaceId=ws_WuwAJnJobgVN2wdMCvZdPR

Steps to Reproduce the Bug or Issue

Create a page, using the table full use case example - https://nextui.org/docs/components/table#use-case-example

Expected behavior

No Hydration Error

Screenshots or Videos

image image

Operating System Version

Linux

Browser

Firefox

TwoWheelDev avatar Dec 17 '24 17:12 TwoWheelDev

I also face this issue, is it fixed or still happening?

shahinali-dev avatar Dec 21 '24 05:12 shahinali-dev

This worked for me. Might not be an ideal solution.

stiyyagura0901 avatar Dec 22 '24 19:12 stiyyagura0901

我也遇到这样的错误存在,只要将表格切换为多选模式。 I also encountered such an error, just switch the table to multi select mode.

"@nextui-org/table": "^2.2.7", "next": "15.1.0", "react": "18.3.1", "react-dom": "18.3.1", "typescript": "5.6.3"

largeprob avatar Dec 25 '24 14:12 largeprob

+1

SivaGanesh56 avatar Dec 26 '24 11:12 SivaGanesh56

I also face this issue, Don't use use NextThemeProvider as they talked about in suggested solution above.

J4v4Scr1pt avatar Jan 02 '25 15:01 J4v4Scr1pt

NextThemeProvider has nothing to do with this, you can see that the code sample doesn't even use it, the issue is that an extra th is injected for row selection

michaeltintiuc avatar Jan 23 '25 19:01 michaeltintiuc

Also having this issue, not using the NextThemeProvider. Removing the selectionMode="multiple" from the <Table> removes the error. any updates on this?

tartane avatar Feb 20 '25 15:02 tartane

Facing same issue with selectionMode="multiple". I hope we'll having fix as it's a quite common feature to have multi selection on table.

nohira avatar Feb 24 '25 10:02 nohira

this still an annoying issue :c

davidaragundy avatar Feb 25 '25 17:02 davidaragundy

for now, you can use:

import dynamic from "next/dynamic";

const Table = dynamic(() => import("@heroui/table").then((c) => c.Table), {
  ssr: false,
});

This MUST be inside a client component

davidaragundy avatar Feb 25 '25 17:02 davidaragundy

Same issue here.

lukasssicevs avatar Mar 07 '25 15:03 lukasssicevs

Same issue

JosepCumplido avatar Mar 16 '25 17:03 JosepCumplido

MM25Zamanian avatar Mar 31 '25 13:03 MM25Zamanian

+1

joshuarussell10 avatar Apr 12 '25 17:04 joshuarussell10

The fix above works well. I was doing this to get the error to go away:

const [isHydrated, setIsHydrated] = useState(false);

useEffect(() => {
    setIsHydrated(true);

    return () => {
      setIsHydrated(false);
    };
  }, []);

edarioq avatar May 04 '25 13:05 edarioq