1

I used sanity with nextjs-13 to build a blog, and I now want to add the live-preview mode to it, but every time I hit the /api/preview to enable the preview mode, I get thrown this error:

TypeError: useReducer only works in Client Components. Add the "use client" directive at the top of the file to use it.

error screenshot

Any help would be much appreciated. Thank you

abelamos
  • 13
  • 6
  • Does this answer your question? [You're importing a component that needs useState. It only works in a Client Component, but none of its parents are marked with "use client"](https://stackoverflow.com/questions/74965849/youre-importing-a-component-that-needs-usestate-it-only-works-in-a-client-comp) – Youssouf Oumar Mar 20 '23 at 14:46
  • Not quite. I have added the "use client" market at the top of the page but the error still persists. -- @yousoumar – abelamos Mar 20 '23 at 16:06

0 Answers0