We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
function App() { let drawerWidth = 240; let prefersDarkMode = useMediaQuery('(prefers-color-scheme: dark)'); let theme = createMemo(() => { console.log('prefersDarkMode=', prefersDarkMode()); return createTheme({ palette: { mode: prefersDarkMode() ? 'dark' : 'light', primary: { main: prefersDarkMode() ? '#b39ddb' : '#673ab7', }, secondary: { main: prefersDarkMode() ? '#673ab7' : '#651fff', }, }, typography: { fontFamily: [ '-apple-system', 'BlinkMacSystemFont', '"Segoe UI"', 'Roboto', '"Helvetica Neue"', 'Arial', 'sans-serif', '"Apple Color Emoji"', '"Segoe UI Emoji"', '"Segoe UI Symbol"', ].join(','), } }); }); return ( <SerialProvider> <ThemeProvider theme={theme()}> .... </ThemeProvider> </SerialProvider> ); }
I see console.log('prefersDarkMode=', prefersDarkMode()); on the console, but the theme is not changed.
console.log('prefersDarkMode=', prefersDarkMode());
The text was updated successfully, but these errors were encountered:
Encountered the same issue just recently. Basically you don't need to use createMemo for theme variable. Below is the code that worked for me.
const palette = createMemo(() => { return createPalette(mode() === 'light' ? light : dark) }) const theme = createTheme({ palette }) <ThemeProvider theme={theme}></...>
yet you can read this to see more details about it.
Sorry, something went wrong.
No branches or pull requests
I see
console.log('prefersDarkMode=', prefersDarkMode());
on the console, but the theme is not changed.The text was updated successfully, but these errors were encountered: