next-mdx-remote/rsc with next-sanity LiveQuery
xecei opened this issue · comments
Hello! i faced a problem with integrating next-mdx-remote/rsc with sanity.
How can i use next-mdx-remote/rsc with LiveQuery?
When we provide Mdx content to LiveQuery we use
<LiveQuery
enabled={draftMode().isEnabled}
initialData={data}
query={postQuery}
as={PreviewPostLayout}
>
<Post data={data} />
</LiveQuery>
and I provide PreviewPostLayout like
"use client";
import dynamic from "next/dynamic";
export const PreviewPostLayout = dynamic(() => import("./post"));
as a result - next-mdx-remote/rsc not working because it's a client component now
The LiveQuery
component only supports RSC components when enabled={false}
. The JSX render tree you give the as
prop is required to be use client
compatible, as we're running code in the browser to listen to updates in real-time.
This means you'll need to setup MDX twice, with the second time being for usage in live preview which has to be a client component.