admin管理员组文章数量:1353235
I have a route in Next.js 15. It is a server component as I am fetching data from an api written in actions folder.
I have written a client component as I have to use a hook.
Below is the code:
app/marketplace/page.js
import { GetAllCourses } from "@/actions/api";
import MarketplaceComponent from "@/app/marketplace/marketplace_component";
export default async function Marketplace() {
const { data } = await GetAllCourses();
return (
<>
<MarketplaceComponent data={data} />
</>
)
}
As you can see I am importing MarketplaceComponent
which is a client component
app/marketplace/marketplace_component.js
'use client';
import { useNetwork } from "@/components/hooks/web3/useNetwork";
import CourseList from "@/components/ui/course/CourseList";
const MarketplaceComponent = ({ data }) => {
const { network } = useNetwork();
return (
<>
{network.data}
<CourseList courses={data} />
</>
)
}
export default MarketplaceComponent;
But I am getting the following error:
I believe we can include client component in a server component. Please can somebody explain the error and how can i fix it.
Thanks.
本文标签: nextjs 15Include a client component as children of server component nextjs 15Stack Overflow
版权声明:本文标题:nextjs 15 - Include a client component as children of server component next.js 15 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743928228a2563358.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论