Replies: 1 comment
-
this is causing because you are trying to use context hooks in Next.js which is by default uses SSR, if you still want to use
example"use client";
import { createContext, useContext } from 'react';
import { useSession } from '../lib/useSession';
export const AppUserContext = createContext({
session: null,
profile: null
});
export default function AppUserProvider({ children }) {
const appUserInfo = useSession();
return (
<AppUserContext.Provider value={appUserInfo}>
<>{children}</>
</AppUserContext.Provider>
);
}
export const useAppUserGlobalContext = () => {
const context = useContext(AppUserContext);
if (context === undefined) {
throw new Error('data must be used inside AppUserProvider');
}
return context;
};
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Is there support for server components in Next.js?
I'm trying to use it with this example using the app directory instead of pages, but I'm getting an error:
Beta Was this translation helpful? Give feedback.
All reactions