Skip to content

Commit

Permalink
Fixing use of useInstanceId
Browse files Browse the repository at this point in the history
Dropping the old `useUniqueId` pattern in favour of the more succinct and complete `useInstanceId` usage.
  • Loading branch information
Andrew Hayward committed Jul 12, 2023
1 parent 2f1f2a5 commit 9da368d
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions packages/components/src/text-control/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 >
Expand All @@ -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 );

Expand Down

0 comments on commit 9da368d

Please sign in to comment.