Skip to content

Commit 783a770

Browse files
committed
use useId
1 parent 157537f commit 783a770

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

packages/block-editor/src/hooks/layout.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import classnames from 'classnames';
66
/**
77
* WordPress dependencies
88
*/
9-
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
9+
import { createHigherOrderComponent } from '@wordpress/compose';
1010
import { addFilter } from '@wordpress/hooks';
1111
import { getBlockSupport, hasBlockSupport } from '@wordpress/blocks';
1212
import { useSelect } from '@wordpress/data';
@@ -17,6 +17,7 @@ import {
1717
PanelBody,
1818
} from '@wordpress/components';
1919
import { __ } from '@wordpress/i18n';
20+
import { useId } from '@wordpress/element';
2021

2122
/**
2223
* Internal dependencies
@@ -360,7 +361,7 @@ export const withLayoutStyles = createHigherOrderComponent(
360361
} );
361362
const shouldRenderLayoutStyles =
362363
blockSupportsLayout && ! disableLayoutStyles;
363-
const id = useInstanceId( BlockListBlock );
364+
const id = useId();
364365
const { layout } = attributes;
365366
const { default: defaultBlockLayout } =
366367
getBlockSupport( name, layoutBlockSupportKey ) || {};
@@ -432,7 +433,7 @@ export const withChildLayoutStyles = createHigherOrderComponent(
432433
const shouldRenderChildLayoutStyles =
433434
hasChildLayout && ! disableLayoutStyles;
434435

435-
const id = useInstanceId( BlockListBlock );
436+
const id = useId();
436437
const selector = `.wp-container-content-${ id }`;
437438

438439
let css = '';

packages/block-editor/src/hooks/position.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ import {
1212
BaseControl,
1313
privateApis as componentsPrivateApis,
1414
} from '@wordpress/components';
15-
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
15+
import { createHigherOrderComponent } from '@wordpress/compose';
1616
import { useSelect } from '@wordpress/data';
17-
import { useMemo, Platform } from '@wordpress/element';
17+
import { useMemo, Platform, useId } from '@wordpress/element';
1818
import { addFilter } from '@wordpress/hooks';
1919

2020
/**
@@ -359,7 +359,7 @@ export const withPositionStyles = createHigherOrderComponent(
359359
const allowPositionStyles =
360360
hasPositionBlockSupport && ! isPositionDisabled;
361361

362-
const id = useInstanceId( BlockListBlock );
362+
const id = useId();
363363

364364
// Higher specificity to override defaults in editor UI.
365365
const positionSelector = `.wp-container-${ id }.wp-container-${ id }`;

packages/block-editor/src/hooks/style.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import classnames from 'classnames';
66
/**
77
* WordPress dependencies
88
*/
9-
import { useMemo } from '@wordpress/element';
9+
import { useMemo, useId } from '@wordpress/element';
1010
import { addFilter } from '@wordpress/hooks';
1111
import {
1212
getBlockSupport,
1313
hasBlockSupport,
1414
__EXPERIMENTAL_ELEMENTS as ELEMENTS,
1515
} from '@wordpress/blocks';
16-
import { createHigherOrderComponent, useInstanceId } from '@wordpress/compose';
16+
import { createHigherOrderComponent } from '@wordpress/compose';
1717
import { getCSSRules, compileCSS } from '@wordpress/style-engine';
1818

1919
/**
@@ -400,7 +400,7 @@ const elementTypes = [
400400
*/
401401
const withElementsStyles = createHigherOrderComponent(
402402
( BlockListBlock ) => ( props ) => {
403-
const blockElementsContainerIdentifier = `wp-elements-${ useInstanceId(
403+
const blockElementsContainerIdentifier = `wp-elements-${ useId(
404404
BlockListBlock
405405
) }`;
406406

0 commit comments

Comments
 (0)