Skip to content

How to use flowbite-react in React Server Components #448

@focux

Description

@focux

Describe the bug
There are some static components that should work on server components (Next.js 13), for instance, the avatar component—and many others—but for some reason is throwing the error below that seems to be coming from floating-ui:

You're importing a component that needs flushSync. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.

   ,----
 5 | import { createPortal, flushSync } from 'react-dom';
   :                        ^^^^^^^^^
   `----

Maybe one of these should be marked as a client entry with "use client":
  ../../node_modules/.pnpm/@floating-ui+react-dom-interactions@0.9.3_2zx2umvpluuhvlq44va5bta2da/node_modules/@floating-ui/react-dom-interactions/dist/floating-ui.react-dom-interactions.mjs

To Reproduce
Steps to reproduce the behavior:

  1. Create a Next.js 13 project—or any other framework that uses server components.
  2. Render an Avatar component on a server component page.
  3. See the error

Expected behavior
Static components should work on server components

System information:

  • Device: Macbook
  • OS: Mac OS
  • Browser: Chrome
  • Version: Latest

Project information:

  • Tailwind: 3.0.0
  • Flowbite: 1.4.7
  • Flowbite React: 0.1.2
  • Type: Next.js 13

Metadata

Metadata

Assignees

Labels

🐛 bugSomething isn't workingconfirmedThis bug was confirmednextjsworkaroundMaybe a bug, but it has a workaround.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions