Skip to content

Commit b7d66af

Browse files
authored
[system] Fix dark mode flicker using useEnhancedEffect (#44812)
1 parent 5d3028f commit b7d66af

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

packages/mui-system/src/cssVars/createCssVarsProvider.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as React from 'react';
22
import PropTypes from 'prop-types';
33
import { GlobalStyles } from '@mui/styled-engine';
44
import { useTheme as muiUseTheme } from '@mui/private-theming';
5+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
56
import ThemeProvider from '../ThemeProvider';
67
import InitColorSchemeScript, {
78
DEFAULT_COLOR_SCHEME_STORAGE_KEY,
@@ -173,7 +174,7 @@ export default function createCssVarsProvider(options) {
173174
// 5. Declaring effects
174175
// 5.1 Updates the selector value to use the current color scheme which tells CSS to use the proper stylesheet.
175176
const colorSchemeSelector = restThemeProp.colorSchemeSelector;
176-
React.useEffect(() => {
177+
useEnhancedEffect(() => {
177178
if (
178179
colorScheme &&
179180
colorSchemeNode &&

0 commit comments

Comments
 (0)