Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Table component not compatible with Server Components #1574

Open
a-corsini opened this issue Sep 5, 2023 · 10 comments
Open

[BUG] - Table component not compatible with Server Components #1574

a-corsini opened this issue Sep 5, 2023 · 10 comments
Labels
🐛 Type: Bug Something isn't working

Comments

@a-corsini
Copy link

NextUI Version

2.0.20

Describe the bug

When trying to use the Table component (together with its respective subcomponents: TableHeader, TableColumn, TableBody, etc.) in a Server Component, the rendering fails with an error Unknown element <[object Object]> in collection.

Adding the 'use client' directive at the top of the file fixes the issue.

Is there any way to use the Table component natively in Server Components?

Thanks!

Your Example Website or App

No response

Steps to Reproduce the Bug or Issue

  1. Copy the code from https://nextui.org/docs/components/table#usage
  2. Paste it into a Server Component
  3. Expect an error during rendering

Expected behavior

I expected the Table to be fully compatible with Server Components.

Screenshots or Videos

No response

Operating System Version

macOS

Browser

Safari

@a-corsini a-corsini added the 🐛 Type: Bug Something isn't working label Sep 5, 2023
@yuki-yuki-engineer
Copy link

I have the same problem.

@jrgarciadev
Copy link
Member

Hey please check this comment: #1403 (comment)

@mo-mainstream
Copy link

hello, I'm still getting this error even after adding use client at the top of the file.
image

I'm using "@nextui-org/table": "^2.0.23" and the latest nextjs 13.5.3 with App Router.

@ARajgor
Copy link

ARajgor commented Oct 15, 2023

Server-side rendering doesn't work in table components.

image

The current workaround is "use client" It works fine for me.
I use create table.tsx in the components folder and import it into different server-side files. or you can directly write into the main file.

My dependencies,

"@nextui-org/react": "^2.1.13",
"framer-motion": "^10.16.4",
"next": "13.5.4",
"react": "^18",
"react-dom": "^18"

image
image
image

@itsdapi
Copy link

itsdapi commented Apr 26, 2024

Any catch up on this?

@leomerida15
Copy link

I have already tried the solution of adding "@nextui-org/tablet" and using the "use client" in more nested components and the error continues
Operating System Version
linux (zorin - ubuntu)
Browser
edge

@Paratron
Copy link

This still happens here in Next.js 14

@phdulac
Copy link

phdulac commented Oct 18, 2024

Same problem here on next15

@Diego-Barrera-07
Copy link

Most of these bugs are generated because the use client is missing, although the library does not explain it, it probably uses react hooks which is why it fails.

Solution: Use "use client" in your component that wraps the table or tab.

@Paratron
Copy link

This is not really a solution but a workaround which adds unnecessary code to the frontend runtime. You should not be required to hydrate a static table...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants