ReactServerComponentsError when using with Dynamic Routing in Next.js 13.4 App Router configuration
SeeYangZhi opened this issue · 1 comments
SeeYangZhi commented
ReactServerComponentsError:
You're importing a component that needs createContext. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default.
import { nestLists, LIST_NEST_MODE_HTML, isPortableTextToolkitList, isPortableTextListItemBlock, isPortableTextToolkitSpan, spanToPlainText, isPortableTextBlock, isPortableTextToolkitTextNode, buildMarksTree } from "@portabletext/toolkit";
export { toPlainText } from "@portabletext/toolkit";
import React, { createContext, useMemo, useContext } from "react";
^^^^^^^^^^^^^
The error was caused by importing '@portabletext/react/dist/react-portable-text.mjs' in './app/blogs/[slug]/page.tsx'.
Maybe one of these should be marked as a client entry with "use client":
The current workaround is likely to wrap it with a customer wrapper that as 'use client'.