Skip to content

Divider resolves to undefined when passed via Stack's divider prop in a React Server Component #48214

@iliarubashkin-movecars

Description

@iliarubashkin-movecars

Steps to reproduce

Live example: https://github.com/iliarubashkin-movecars/mui-stack-divider-rsc-bug

Steps to reproduce:

  1. Create a server component (page.tsx, no "use client" directive)
  2. Use <Stack divider={}> with 2+ children
  3. The page crashes with:
Error: Element type is invalid: expected a string (for built-in components)
or a class/function (for composite components) but got: undefined

Current behavior

When <Divider> is passed via Stack's divider prop inside a React Server Component, it resolves to undefined during server rendering. With 1 child nothing breaks (no divider is inserted), but with 2+ children Stack injects the undefined component between them, causing a runtime crash.

Next.js automatically handles the "use client" boundary for MUI components when they are rendered as direct JSX children — but this mechanism does not work when a client component is passed as a prop value. This likely affects any MUI client component passed as a prop value in a server component, not just Divider.

The error message gives no indication that this is an RSC boundary issue, making it extremely difficult to debug.

Expected behavior

Stack with divider={<Divider />} should render dividers between children in a server component, the same way it works when <Divider> is used as a direct JSX child. Next.js should handle the "use client" boundary for components passed as prop values the same way it handles them as JSX children.

Context

Building a company profile page in Next.js App Router where the page component is an async server component (it fetches data via GraphQL). Using <Stack divider={<Divider />}> to visually separate sections of the profile. The page must remain a server component because it performs data fetching — adding "use client" to the entire page is not an option.

Your environment

npx @mui/envinfo
System:
  OS: Linux 6.8 Linux Mint 21.3 (Virginia)
Binaries:
  Node: 24.12.0 - /home/movecars/.asdf/installs/nodejs/24.12.0/bin/node
  npm: 11.6.2 - /home/movecars/.asdf/plugins/nodejs/shims/npm
  pnpm: 10.29.3 - /home/movecars/.asdf/shims/pnpm
Browsers:
  Chrome: 146.0.7680.177
  Firefox: 149.0

The issue is present in both Firefox and Chrome

Search keywords: Divider, Stack, divider prop, server component, RSC, undefined, Element type is invalid, use client, Next.js, App Router

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions