Skip to content

Commit

Permalink
Make toggle callbacks stable
Browse files Browse the repository at this point in the history
  • Loading branch information
stokesman committed Sep 29, 2024
1 parent df3451b commit 5db7309
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions packages/components/src/tools-panel/tools-panel-item/hook.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* WordPress dependencies
*/
import { usePrevious } from '@wordpress/compose';
import { useEvent, usePrevious } from '@wordpress/compose';
import {
useCallback,
useEffect,
Expand Down Expand Up @@ -31,8 +31,8 @@ export function useToolsPanelItem(
label,
panelId,
resetAllFilter = noop,
onDeselect,
onSelect,
onDeselect: onDeselectProp,
onSelect: onSelectProp,
...otherProps
} = useContextSystem( props, 'ToolsPanelItem' );

Expand All @@ -59,6 +59,8 @@ export function useToolsPanelItem(
// dependency to the useCallback hook! If needed, we should use a ref.
// eslint-disable-next-line react-hooks/exhaustive-deps
const resetAllFilterCallback = useCallback( resetAllFilter, [ panelId ] );
const onDeselect = useEvent( onDeselectProp );
const onSelect = useEvent( onSelectProp );
const previousPanelId = usePrevious( currentPanelId );

const hasMatchingPanel =
Expand Down

0 comments on commit 5db7309

Please sign in to comment.