From 2d5119f603b995c14bf88ff68fb5e7c9a432d5a3 Mon Sep 17 00:00:00 2001 From: Robert Snow Date: Thu, 9 Nov 2023 07:18:52 +1100 Subject: [PATCH] Reduce dom checks for toolbar (#5386) --- packages/@react-aria/actiongroup/src/useActionGroup.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/@react-aria/actiongroup/src/useActionGroup.ts b/packages/@react-aria/actiongroup/src/useActionGroup.ts index 69161b3404f..f4f749f1ae3 100644 --- a/packages/@react-aria/actiongroup/src/useActionGroup.ts +++ b/packages/@react-aria/actiongroup/src/useActionGroup.ts @@ -35,12 +35,9 @@ export function useActionGroup(props: AriaActionGroupProps, state: ListSta } = props; let [isInToolbar, setInToolbar] = useState(false); - // should be safe because re-calling set state with the same value it already has is a no-op - // this will allow us to react should a parent re-render and change its role though - // eslint-disable-next-line react-hooks/exhaustive-deps useLayoutEffect(() => { setInToolbar(!!(ref.current && ref.current.parentElement?.closest('[role="toolbar"]'))); - }); + }, [ref]); let allKeys = [...state.collection.getKeys()]; if (!allKeys.some(key => !state.disabledKeys.has(key))) {