I ran into some weird behavior in Next js 13 while trying to do a simple action. I have prepared the most simple example showing the problem. I hope you can help me figure out why this is happening.
There are 3 components.
page:
import {Container} from '../components/Container'
export default function index() {
return (
<Container>
<Container.Window>
<h1>12345</h1>
</Container.Window>
</Container>
)
}
Container:
'use client';
import { Window } from './Window';
export const Container = ({ children }) => {
return children;
};
Container.Window = Window;
Window:
"use client";
export const Window = ({children})=>{
return children
}
Page server component. The Container and Window components are client-side. Container imports and exports Window.
I am getting this error:
"Unsupported Server Component type: undefined"
Import the Window component separately.
Works, no errorsMake the Container component a server component.
Works, no errorsMake the page component client-side.
Works, no errors
But I think the first option is the most convenient. Would love to make it work