From 9da368df18f970c2945fe4bd9ae29f758f5f368d Mon Sep 17 00:00:00 2001 From: Andrew Hayward Date: Wed, 12 Jul 2023 16:02:10 +0200 Subject: [PATCH] Fixing use of `useInstanceId` Dropping the old `useUniqueId` pattern in favour of the more succinct and complete `useInstanceId` usage. --- packages/components/src/text-control/index.tsx | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/packages/components/src/text-control/index.tsx b/packages/components/src/text-control/index.tsx index e2f85eef07f56..34c9028c1cb8b 100644 --- a/packages/components/src/text-control/index.tsx +++ b/packages/components/src/text-control/index.tsx @@ -16,13 +16,6 @@ import BaseControl from '../base-control'; import type { WordPressComponentProps } from '../ui/context'; import type { TextControlProps } from './types'; -function useUniqueId( idProp?: string ) { - const instanceId = useInstanceId( TextControl ); - const id = `inspector-text-control-${ instanceId }`; - - return idProp || id; -} - function UnforwardedTextControl( props: WordPressComponentProps< TextControlProps, 'input', false >, ref: ForwardedRef< HTMLInputElement > @@ -39,7 +32,7 @@ function UnforwardedTextControl( type = 'text', ...additionalProps } = props; - const id = useUniqueId( idProp ); + const id = useInstanceId( TextControl, 'inspector-text-control', idProp ); const onChangeValue = ( event: ChangeEvent< HTMLInputElement > ) => onChange( event.target.value );