Skip to content

Commit d75a6be

Browse files
committed
Use in operator to check if the deprecated unit prop is passed to UnitControl
1 parent 5b6be2d commit d75a6be

File tree

1 file changed

+11
-5
lines changed
  • packages/components/src/unit-control

1 file changed

+11
-5
lines changed

packages/components/src/unit-control/index.tsx

+11-5
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,14 @@ import type { UnitControlProps, UnitControlOnChangeCallback } from './types';
3636
import type { StateReducer } from '../input-control/reducer/state';
3737

3838
function UnforwardedUnitControl(
39-
{
39+
unitControlProps: WordPressComponentProps<
40+
UnitControlProps,
41+
'input',
42+
false
43+
>,
44+
forwardedRef: ForwardedRef< any >
45+
) {
46+
const {
4047
__unstableStateReducer: stateReducerProp,
4148
autoComplete = 'off',
4249
className,
@@ -54,10 +61,9 @@ function UnforwardedUnitControl(
5461
units: unitsProp = CSS_UNITS,
5562
value: valueProp,
5663
...props
57-
}: WordPressComponentProps< UnitControlProps, 'input', false >,
58-
forwardedRef: ForwardedRef< any >
59-
) {
60-
if ( typeof unitProp !== 'undefined' ) {
64+
} = unitControlProps;
65+
66+
if ( 'unit' in unitControlProps ) {
6167
deprecated( 'UnitControl unit prop', {
6268
since: '5.6',
6369
hint: 'The unit should be provided within the `value` prop.',

0 commit comments

Comments
 (0)