Next.js Discord

Discord Forum

Help with state management

Unanswered
Common Black-Hawk posted this in #help-forum
Open in Discord
Avatar
Common Black-HawkOP
So I want to be able to access the state of a component (filename = langselector.jsx. I want to know the language selected in every part of the project) so I asked chatgpt and he told me to this


First image is src/app/components/context.jsx

Second image is src/app/components/langselector.jsx

Third image is src/app/layout.js

Fourth image is where I want to access it.

It outputs an error saying useLanguage is not a function, i bet this has something to do with the 'use client' stuff, I really dont get whats the point of it, other next.js versions didnt have that
Image
Image
Image
Image

0 Replies