-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Bug: fails to compile on nextjs Client Component SSR - Error: Element type is invalid: expected a string #5823
Copy link
Copy link
Closed
Description
Lexical version: 0.14.3
Steps To Reproduce
- clone https://github.com/2wheeh/nextjs-lexical-build-error
- try build (or compile dynamic route pages by accessing
localhost:3000/not-work/hi)
Link to code example: https://github.com/2wheeh/nextjs-lexical-build-error
The current behavior
Call apis or anything imported from Lexical in ClientComponent (with 'use client' directive).
Rendering this component in nextjs server side fails.
// client-component.tsx
'use client';
import { COMMAND_PRIORITY_CRITICAL } from 'lexical'; // just a simple constant.
export default function ClientComponent() {
COMMAND_PRIORITY_CRITICAL;
return <>hi</>;
}// not-work/page.tsx
import ClientComponent from '../client-component';
export default function Page() {
return <ClientComponent />;
}Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined.
build time: fails to generate static pages.
run time: fails to compile dynamic ssr pages.
Now It only works with dynamic imports with no ssr.
// work/page.tsx
import dynamic from 'next/dynamic';
const ClientComponent = dynamic(() => import('../client-component'), { ssr: false });
export default function Page() {
return <ClientComponent />;
}The expected behavior
works well as it was til 0.14.2
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels