Skip to content

Commit

Permalink
[system] Fix dark mode flicker using useEnhancedEffect (#44812)
Browse files Browse the repository at this point in the history
  • Loading branch information
siriwatknp authored Jan 20, 2025
1 parent 5d3028f commit b7d66af
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/mui-system/src/cssVars/createCssVarsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import PropTypes from 'prop-types';
import { GlobalStyles } from '@mui/styled-engine';
import { useTheme as muiUseTheme } from '@mui/private-theming';
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
import ThemeProvider from '../ThemeProvider';
import InitColorSchemeScript, {
DEFAULT_COLOR_SCHEME_STORAGE_KEY,
Expand Down Expand Up @@ -173,7 +174,7 @@ export default function createCssVarsProvider(options) {
// 5. Declaring effects
// 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
const colorSchemeSelector = restThemeProp.colorSchemeSelector;
React.useEffect(() => {
useEnhancedEffect(() => {
if (
colorScheme &&
colorSchemeNode &&
Expand Down

0 comments on commit b7d66af

Please sign in to comment.