From 04a614534681ff464975613de200310bf7c47c5d Mon Sep 17 00:00:00 2001 From: Jan Potoms <2109932+Janpot@users.noreply.github.com> Date: Fri, 28 Oct 2022 11:53:22 -0700 Subject: [PATCH] [core] memoize context values for react/jsx-no-constructed-context-values (#34849) --- docs/data/base/components/menu/UseMenu.js | 17 ++++--- docs/data/base/components/menu/UseMenu.tsx | 17 ++++--- docs/pages/_app.js | 7 ++- .../app/entry.client.tsx | 13 +++-- .../FormControlUnstyled.tsx | 40 +++++++-------- .../src/MenuUnstyled/MenuUnstyled.tsx | 17 ++++--- .../MultiSelectUnstyled.tsx | 13 +++-- .../src/SelectUnstyled/SelectUnstyled.tsx | 13 +++-- .../mui-joy/src/AvatarGroup/AvatarGroup.tsx | 17 ++++--- packages/mui-joy/src/Chip/Chip.tsx | 7 ++- .../mui-joy/src/FormControl/FormControl.tsx | 33 ++++++------ packages/mui-joy/src/Menu/Menu.tsx | 17 ++++--- packages/mui-joy/src/MenuList/MenuList.tsx | 20 +++++--- .../mui-joy/src/ModalDialog/ModalDialog.tsx | 4 +- .../mui-joy/src/RadioGroup/RadioGroup.tsx | 39 +++++++------- packages/mui-joy/src/Select/Select.tsx | 15 +++--- packages/mui-lab/src/Timeline/Timeline.tsx | 5 +- .../mui-lab/src/TimelineItem/TimelineItem.js | 7 ++- packages/mui-lab/src/TreeView/TreeView.js | 2 + .../src/FormControl/FormControl.js | 51 +++++++++++-------- .../mui-material/src/ListItem/ListItem.js | 13 +++-- .../src/ListItemButton/ListItemButton.js | 13 +++-- .../mui-material/src/MenuItem/MenuItem.js | 11 ++-- .../mui-material/src/RadioGroup/RadioGroup.js | 23 ++++++--- .../src/ThemeProvider/ThemeProvider.js | 4 +- .../src/cssVars/createCssVarsProvider.js | 36 ++++++++----- 26 files changed, 276 insertions(+), 178 deletions(-) diff --git a/docs/data/base/components/menu/UseMenu.js b/docs/data/base/components/menu/UseMenu.js index d495d627a0b845..df277a54b158fc 100644 --- a/docs/data/base/components/menu/UseMenu.js +++ b/docs/data/base/components/menu/UseMenu.js @@ -150,13 +150,16 @@ const Menu = React.forwardRef(function Menu(props, ref) { open, }); - const contextValue = { - registerItem, - unregisterItem, - getItemState, - getItemProps, - open: true, - }; + const contextValue = React.useMemo( + () => ({ + registerItem, + unregisterItem, + getItemState, + getItemProps, + open: true, + }), + [getItemProps, getItemState, registerItem, unregisterItem], + ); return (