From d75a6be408fe0f5c9173784f28ece9bfc8b7e8a4 Mon Sep 17 00:00:00 2001 From: Marco Ciampini Date: Fri, 18 Mar 2022 19:03:10 +0100 Subject: [PATCH] Use `in` operator to check if the deprecated `unit` prop is passed to `UnitControl` --- packages/components/src/unit-control/index.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/packages/components/src/unit-control/index.tsx b/packages/components/src/unit-control/index.tsx index 8b5028970026c..14092ad899625 100644 --- a/packages/components/src/unit-control/index.tsx +++ b/packages/components/src/unit-control/index.tsx @@ -36,7 +36,14 @@ import type { UnitControlProps, UnitControlOnChangeCallback } from './types'; import type { StateReducer } from '../input-control/reducer/state'; function UnforwardedUnitControl( - { + unitControlProps: WordPressComponentProps< + UnitControlProps, + 'input', + false + >, + forwardedRef: ForwardedRef< any > +) { + const { __unstableStateReducer: stateReducerProp, autoComplete = 'off', className, @@ -54,10 +61,9 @@ function UnforwardedUnitControl( units: unitsProp = CSS_UNITS, value: valueProp, ...props - }: WordPressComponentProps< UnitControlProps, 'input', false >, - forwardedRef: ForwardedRef< any > -) { - if ( typeof unitProp !== 'undefined' ) { + } = unitControlProps; + + if ( 'unit' in unitControlProps ) { deprecated( 'UnitControl unit prop', { since: '5.6', hint: 'The unit should be provided within the `value` prop.',