From a08c8f0f8052d78d0a9ff8cabc08064324bb97b1 Mon Sep 17 00:00:00 2001 From: asvarcas Date: Sat, 8 May 2021 15:31:37 -0300 Subject: [PATCH] Avoid Material-UI's createMuiTheme running on every layout render --- packages/ra-ui-materialui/src/layout/Layout.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/ra-ui-materialui/src/layout/Layout.tsx b/packages/ra-ui-materialui/src/layout/Layout.tsx index 833685776f1..3cfcf35acb7 100644 --- a/packages/ra-ui-materialui/src/layout/Layout.tsx +++ b/packages/ra-ui-materialui/src/layout/Layout.tsx @@ -229,7 +229,7 @@ const Layout = ({ ...props }: LayoutProps): JSX.Element => { const themeProp = useRef(themeOverride); - const [theme, setTheme] = useState(createMuiTheme(themeOverride)); + const [theme, setTheme] = useState(() => createMuiTheme(themeOverride)); useEffect(() => { if (themeProp.current !== themeOverride) {