You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello,
I'm using the Maintine UI and I would like to use the dark mode.
In order to do that, I need to use the getInitialProps() in my _app.tsx.
By adding the Mantine example
MyApp.getInitialProps=({ ctx }: {ctx: GetServerSidePropsContext})=>({// get color scheme from cookiecolorScheme: getCookie('mantine-color-scheme',ctx)||'light',});
the pageProps.session becomes undefined
exportdefaultfunctionMyApp({
Component,
pageProps,}: AppPropsWithLayout){// Use the layout defined at the page level, if availableconstgetLayout=Component.getLayout??((page)=>page);// hook will return either 'dark' or 'light' on client// and always 'light' during ssr as window.matchMedia is not availableconstpreferredColorScheme=useColorScheme();const[colorScheme,setColorScheme]=useState<ColorScheme>(preferredColorScheme);console.log("!!!!",{ colorScheme, setColorScheme, preferredColorScheme });consttoggleColorScheme=(value?: ColorScheme)=>{constnextColorScheme=value||(colorScheme==="dark" ? "light" : "dark");setColorScheme(nextColorScheme);// when color scheme is updated save it to cookiesetCookie("mantine-color-scheme",nextColorScheme,{maxAge: 60*60*24*30,});};return(<ColorSchemeProvidercolorScheme={colorScheme}toggleColorScheme={toggleColorScheme}><MantineProviderwithGlobalStyleswithNormalizeCSStheme={{ colorScheme }}><SessionProvidersession={pageProps.session}refetchInterval={0}>{getLayout(<Component{...pageProps}/>)}</SessionProvider></MantineProvider></ColorSchemeProvider>);}
What do I need to do to implement a getSession() or unstable_getServerSession() there?
questionAsk how to do something or how something works
1 participant
Converted from issue
This discussion was converted from issue #5351 on September 16, 2022 23:47.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Question 💬
Hello,
I'm using the Maintine UI and I would like to use the dark mode.
In order to do that, I need to use the
getInitialProps()
in my_app.tsx
.By adding the Mantine example
the
pageProps.session
becomesundefined
What do I need to do to implement a
getSession()
orunstable_getServerSession()
there?How to reproduce ☕️
Use the code sample in the question above
Contributing 🙌🏽
No, I am afraid I cannot help regarding this
Beta Was this translation helpful? Give feedback.
All reactions