You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{client}from"@/sanity/lib/client";import{groq}from"next-sanity";import{flatDataToTree}from"@sanity/hierarchical-document-list";exportdefaultasyncfunctionPage(){constpageHierarchy=awaitclient.fetch(groq`*[_id == "page-hierarchy"][0] { tree[] { // Make sure you include each item's _key and parent _key, parent, value { reference->{ title, slug, content, } } } }`);constpageTree=flatDataToTree(pageHierarchy.tree);return(<div>{JSON.stringify(pageTree,null,2)}</div>);}
doesn't work as a NextJS server component. Error message
TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
The root cause is in the @nosferatu500/react-sortable-tree => react-dnd@14 dependency, which probably exposes some react-context related functionality.
I fixed it by including this code in my repository:
This simple demo
doesn't work as a NextJS server component. Error message
The root cause is in the
@nosferatu500/react-sortable-tree
=>react-dnd@14
dependency, which probably exposes some react-context related functionality.I fixed it by including this code in my repository:
The text was updated successfully, but these errors were encountered: