[BUG] - Hydration Error with Table selectionMode = multiple
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
Operating System Version
Linux
Browser
Firefox
I also face this issue, is it fixed or still happening?
This worked for me. Might not be an ideal solution.
我也遇到这样的错误存在,只要将表格切换为多选模式。 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"
+1
I also face this issue, Don't use use NextThemeProvider as they talked about in suggested solution above.
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
Also having this issue, not using the NextThemeProvider. Removing the selectionMode="multiple" from the <Table> removes the error. any updates on this?
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.
this still an annoying issue :c
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
Same issue here.
Same issue
+1
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);
};
}, []);