From 188a737c99108c04e6ec7dedade03fef3e17d2fc Mon Sep 17 00:00:00 2001 From: alexandre Date: Mon, 8 Apr 2024 11:52:39 +0200 Subject: [PATCH] [docs-infra] Fix drawer performances --- docs/src/modules/components/AppFrame.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/docs/src/modules/components/AppFrame.js b/docs/src/modules/components/AppFrame.js index 9f0d45acc58879..08d1eb2c232786 100644 --- a/docs/src/modules/components/AppFrame.js +++ b/docs/src/modules/components/AppFrame.js @@ -165,6 +165,9 @@ export default function AppFrame(props) { const [mobileOpen, setMobileOpen] = React.useState(false); const [settingsOpen, setSettingsOpen] = React.useState(false); + const closeDrawer = React.useCallback(() => setMobileOpen(false), []); + const openDrawer = React.useCallback(() => setMobileOpen(true), []); + const { activePage } = React.useContext(PageContext); const disablePermanent = activePage?.disableDrawer === true || disableDrawer === true; @@ -229,8 +232,8 @@ export default function AppFrame(props) { setMobileOpen(false)} - onOpen={() => setMobileOpen(true)} + onClose={closeDrawer} + onOpen={openDrawer} mobileOpen={mobileOpen} /> {children}