From b93864f3dc6a48129ce223fbc148d9ef896d1bef Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Mon, 18 Dec 2023 19:52:24 +0100 Subject: [PATCH] Remove unnecessary useMemo --- packages/components/src/button/index.tsx | 43 +++++++++--------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/packages/components/src/button/index.tsx b/packages/components/src/button/index.tsx index bdcd2aef1c8a30..966075dd6e2b9a 100644 --- a/packages/components/src/button/index.tsx +++ b/packages/components/src/button/index.tsx @@ -14,7 +14,7 @@ import type { * WordPress dependencies */ import deprecated from '@wordpress/deprecated'; -import { forwardRef, useMemo } from '@wordpress/element'; +import { forwardRef } from '@wordpress/element'; import { useInstanceId } from '@wordpress/compose'; /** @@ -252,32 +252,21 @@ export function UnforwardedButton( // In order to avoid some React reconciliation issues, we are always rendering // the `Tooltip` component even when `shouldShowTooltip` is `false`. // In order to make sure that the tooltip doesn't show when it shouldn't, - // we don't pass the props to the `Tooltip` componet. - const tooltipProps = useMemo( - () => - ( shouldShowTooltip - ? { - text: - ( children as string | ReactElement[] )?.length && - describedBy - ? describedBy - : label, - shortcut, - placement: - tooltipPosition && - // Convert legacy `position` values to be used with the new `placement` prop - positionToPlacement( tooltipPosition ), - } - : {} ) as Partial< React.ComponentProps< typeof Tooltip > >, - [ - shouldShowTooltip, - children, - describedBy, - label, - shortcut, - tooltipPosition, - ] - ); + // we don't pass the props to the `Tooltip` component. + const tooltipProps = shouldShowTooltip + ? { + text: + ( children as string | ReactElement[] )?.length && + describedBy + ? describedBy + : label, + shortcut, + placement: + tooltipPosition && + // Convert legacy `position` values to be used with the new `placement` prop + positionToPlacement( tooltipPosition ), + } + : {}; return ( <>