Context & Server Components
Answered
Asiatic Lion posted this in #help-forum
Asiatic LionOP
When consuming context within a component, does it have to be marked as a client component? This is something like an AuthButton that I want to use my AuthProvider in, but I get the following error:
The context itself is set as a client component, and wraps the children in the RootLayout component
⨯ TypeError: (0 , _contexts_AuthProvider__WEBPACK_IMPORTED_MODULE_1__.useAuth) is not a function"The context itself is set as a client component, and wraps the children in the RootLayout component
Answered by Ray
yes the
AuthButton need to be client component in order to use the useAuth hook2 Replies
@Asiatic Lion When _consuming_ context within a component, does it have to be marked as a client component? This is something like an AuthButton that I want to use my AuthProvider in, but I get the following error: `⨯ TypeError: (0 , _contexts_AuthProvider__WEBPACK_IMPORTED_MODULE_1__.useAuth) is not a function"`
The context itself is set as a client component, and wraps the children in the RootLayout component
yes the
AuthButton need to be client component in order to use the useAuth hookAnswer
Asiatic LionOP
okay thank you