diff --git a/packages/block-editor/src/components/responsive-block-control/label.js b/packages/block-editor/src/components/responsive-block-control/label.js index 829af3aadec422..038262d126de9e 100644 --- a/packages/block-editor/src/components/responsive-block-control/label.js +++ b/packages/block-editor/src/components/responsive-block-control/label.js @@ -1,11 +1,12 @@ /** * WordPress dependencies */ -import { withInstanceId } from '@wordpress/compose'; +import { useInstanceId } from '@wordpress/compose'; import { _x, sprintf } from '@wordpress/i18n'; import { Fragment } from '@wordpress/element'; -const ResponsiveBlockControlLabel = ( { instanceId, property, viewport, desc } ) => { +export default function ResponsiveBlockControlLabel( { property, viewport, desc } ) { + const instanceId = useInstanceId(); const accessibleLabel = desc || sprintf( _x( 'Controls the %1$s property for %2$s viewports.', 'Text labelling a interface as controlling a given layout property (eg: margin) for a given screen size.' ), property, viewport.label ); return ( @@ -15,7 +16,4 @@ const ResponsiveBlockControlLabel = ( { instanceId, property, viewport, desc } ) { accessibleLabel } ); -}; - -export default withInstanceId( ResponsiveBlockControlLabel ); - +} diff --git a/packages/block-editor/src/components/responsive-block-control/test/__snapshots__/index.js.snap b/packages/block-editor/src/components/responsive-block-control/test/__snapshots__/index.js.snap index 27b9533f39730c..c84811a94da6b3 100644 --- a/packages/block-editor/src/components/responsive-block-control/test/__snapshots__/index.js.snap +++ b/packages/block-editor/src/components/responsive-block-control/test/__snapshots__/index.js.snap @@ -1,3 +1,3 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`Basic rendering should render with required props 1`] = `"
Padding

Toggle between using the same value for all screen sizes or using a unique value per screen size.

All is used here for testing purposes to ensure we have access to details about the device.

"`; +exports[`Basic rendering should render with required props 1`] = `"
Padding

Toggle between using the same value for all screen sizes or using a unique value per screen size.

All is used here for testing purposes to ensure we have access to details about the device.

"`; diff --git a/packages/block-editor/src/components/url-input/index.native.js b/packages/block-editor/src/components/url-input/index.native.js index a76252cadff39a..f08fff246b6f18 100644 --- a/packages/block-editor/src/components/url-input/index.native.js +++ b/packages/block-editor/src/components/url-input/index.native.js @@ -7,29 +7,27 @@ import { TextInput } from 'react-native'; * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { Component } from '@wordpress/element'; -import { withInstanceId } from '@wordpress/compose'; -class URLInput extends Component { - render() { - const { value = '', autoFocus = true, ...extraProps } = this.props; - /* eslint-disable jsx-a11y/no-autofocus */ - return ( - - ); - /* eslint-enable jsx-a11y/no-autofocus */ - } +export default function URLInput( { + value = '', + autoFocus = true, + onChange, + ...extraProps +} ) { + /* eslint-disable jsx-a11y/no-autofocus */ + return ( + + ); + /* eslint-enable jsx-a11y/no-autofocus */ } - -export default withInstanceId( URLInput ); diff --git a/packages/block-library/src/shortcode/edit.js b/packages/block-library/src/shortcode/edit.js index 5a9dbf7f5c7952..50dc5717ae68e4 100644 --- a/packages/block-library/src/shortcode/edit.js +++ b/packages/block-library/src/shortcode/edit.js @@ -4,9 +4,10 @@ import { __ } from '@wordpress/i18n'; import { Dashicon } from '@wordpress/components'; import { PlainText } from '@wordpress/block-editor'; -import { withInstanceId } from '@wordpress/compose'; +import { useInstanceId } from '@wordpress/compose'; -const ShortcodeEdit = ( { attributes, setAttributes, instanceId } ) => { +export default function ShortcodeEdit( { attributes, setAttributes } ) { + const instanceId = useInstanceId(); const inputId = `blocks-shortcode-input-${ instanceId }`; return ( @@ -24,6 +25,4 @@ const ShortcodeEdit = ( { attributes, setAttributes, instanceId } ) => { /> ); -}; - -export default withInstanceId( ShortcodeEdit ); +} diff --git a/packages/components/src/checkbox-control/index.js b/packages/components/src/checkbox-control/index.js index 77f75a33064985..ee934ee2b32f06 100644 --- a/packages/components/src/checkbox-control/index.js +++ b/packages/components/src/checkbox-control/index.js @@ -1,7 +1,7 @@ /** * WordPress dependencies */ -import { withInstanceId } from '@wordpress/compose'; +import { useInstanceId } from '@wordpress/compose'; /** * Internal dependencies @@ -9,7 +9,8 @@ import { withInstanceId } from '@wordpress/compose'; import BaseControl from '../base-control'; import Dashicon from '../dashicon'; -function CheckboxControl( { label, className, heading, checked, help, instanceId, onChange, ...props } ) { +export default function CheckboxControl( { label, className, heading, checked, help, onChange, ...props } ) { + const instanceId = useInstanceId(); const id = `inspector-checkbox-control-${ instanceId }`; const onChangeValue = ( event ) => onChange( event.target.checked ); @@ -34,5 +35,3 @@ function CheckboxControl( { label, className, heading, checked, help, instanceId ); } - -export default withInstanceId( CheckboxControl ); diff --git a/packages/components/src/custom-gradient-picker/control-points.js b/packages/components/src/custom-gradient-picker/control-points.js index 79c7e0017e3deb..bd1f4c6e51a5a6 100644 --- a/packages/components/src/custom-gradient-picker/control-points.js +++ b/packages/components/src/custom-gradient-picker/control-points.js @@ -9,7 +9,7 @@ import classnames from 'classnames'; */ import { Component, useEffect, useRef } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; -import { withInstanceId } from '@wordpress/compose'; +import { useInstanceId } from '@wordpress/compose'; /** * Internal dependencies @@ -68,57 +68,55 @@ class ControlPointKeyboardMove extends Component { } } -const ControlPointButton = withInstanceId( - function( { - instanceId, - isOpen, - position, - color, - onChange, - gradientIndex, - gradientAST, - ...additionalProps - } ) { - const descriptionId = `components-custom-gradient-picker__control-point-button-description-${ instanceId }`; - return ( - -