File tree Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Expand file tree Collapse file tree 1 file changed +13
-11
lines changed Original file line number Diff line number Diff line change @@ -218,8 +218,8 @@ function createMuiDsfrTheme(params: { isDark: boolean }): MuiTheme {
218218 return muiTheme ;
219219}
220220
221- export function createMuiDsfrThemeProvider ( params : {
222- augmentMuiTheme ? : ( params : {
221+ export function createMuiDsfrThemeProvider ( params ? : {
222+ augmentMuiTheme : ( params : {
223223 /** WARNING: The types is lying here.
224224 * It's a Theme as defined in import type { Theme } from "@mui/material/styles";
225225 * That is to say before augmentation.
@@ -228,7 +228,7 @@ export function createMuiDsfrThemeProvider(params: {
228228 frColorTheme : ColorTheme ;
229229 } ) => MuiTheme ;
230230} ) {
231- const { augmentMuiTheme = ( { nonAugmentedMuiTheme } ) => nonAugmentedMuiTheme } = params ;
231+ const { augmentMuiTheme } = params ?? { } ;
232232
233233 type Props = {
234234 children : ReactNode ;
@@ -240,14 +240,16 @@ export function createMuiDsfrThemeProvider(params: {
240240
241241 const { isDark } = useIsDark ( ) ;
242242
243- const theme = useMemo (
244- ( ) =>
245- augmentMuiTheme ( {
246- "frColorTheme" : getColors ( isDark ) ,
247- "nonAugmentedMuiTheme" : createMuiDsfrTheme ( { isDark } )
248- } ) ,
249- [ isDark ]
250- ) ;
243+ const theme = useMemo ( ( ) => {
244+ const nonAugmentedMuiTheme = createMuiDsfrTheme ( { isDark } ) ;
245+
246+ return augmentMuiTheme === undefined
247+ ? nonAugmentedMuiTheme
248+ : augmentMuiTheme ( {
249+ "frColorTheme" : getColors ( isDark ) ,
250+ nonAugmentedMuiTheme
251+ } ) ;
252+ } , [ isDark ] ) ;
251253
252254 return < MuiThemeProvider theme = { theme } > { children } </ MuiThemeProvider > ;
253255 }
You can’t perform that action at this time.
0 commit comments