vercel / next.js

The React Framework
https://nextjs.org
MIT License
126.92k stars 26.98k forks source link

"error createContext only works in Client Components" still exists #60877

Open sheetalsindhu opened 9 months ago

sheetalsindhu commented 9 months ago

What is the improvement or update you wish to see?

I am getting this error in my project, after updating each and every file with "use client" still exists

Is there any context that might help us understand?

"next": "13.4.13", "react": "^18.2.0",

Does the docs page already exist? Please link to it.

https://nextjs.org/docs/messages/context-in-server-component

delbaoliveira commented 9 months ago

Hey @sheetalsindhu, could you please delete your .next directory? Wondering if it's a bad cache.

bonface221 commented 9 months ago

@sheetalsindhu add "use client" on the component with the create context only.

Then wrap the component in your layout or where you intend to use it

e.g this is a client auth provider image

wrapped over other components

image

ryozm commented 9 months ago

I got same error when i use @next/mdx, If this error occurs when you also use mdx, ensure mdx-components.tsx is at the root of your project

47523 https://github.com/vercel/next.js/issues/47523#issuecomment-1558274445

asd58584388 commented 9 months ago

I got the same error, after moving mdx-components.tsx to the root of my project, I solved it.

cleytonoliveira commented 6 months ago

I got the same error trying to migrate from Pages to App. I put the 'use client' at the beginning of my Context, but it doesn't work.

wenzhen-gong commented 6 months ago

I got the same error trying to migrate from Pages to App. I put the 'use client' at the beginning of my Context, but it doesn't work.

Same here. @emotion/styled works perfectly in Pages but not the case in App

Aruseli commented 3 weeks ago

@wenzhen-gong I had this error when I started adding i18n. There were no problems when adding chakra-ui