Open ADTC opened 9 months ago
Hi @ADTC, I'm experiencing the same issue now. Could you share more details of how you managed to work around this error? Thanks!
@chuamatt you can solve this by placing the table inside a client component. If your component is a server component and you need it to stay a server component, just create a separate client component that's a wrapper around the table, then use the wrapper client component inside your server component.
Issue Check list
styled-components
Describe the bug
The component
DataTable
will not work inside React Server Components. This is most relevant to newer versions of Next.js, however, it also applies to non-NextJS projects which use this new React feature.Currently, the workaround is to create a separate client component to host the
DataTable
component inside it, then use the client component inside the original server component.To Reproduce
Steps to reproduce the behavior:
npm run dev
and attempt to load the page in your browser.Expected behavior
DataTable
is automatically a client component.Actual behavior
Code Sandbox, Screenshots, or Relevant Code
Versions (please complete the following information)
Additional context
I believe adding
'use client'
on top of the component source code file will not cause any issues with projects that aren't using React Server Components, as it's a simple string constant which is ignored by systems that aren't designed to understand it.