I started migrating one of my Next.js applications to version 13. I wanted to use the app directory with Server and Client Components. The documentation says that:
Server and Client Components can be interleaved in the same component tree. Behind the scenes, React will merge the work of both environments.
But my below attempt fails with this error:
Error: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.
"use client";
import Comments from "./Comments";
const Post = () => {
return (
<div>
<p>This is a post</p>
<Comments />
</div>
);
};
export default Post;
export default async function Comments() {
const res = await fetch("https://jsonplaceholder.typicode.com/comments");
return <div></div>;
}
I have looked around the Internet and Stack Overflow but didn't find an answer. Any help would be appreciated.