Skip to content

Commit 2e0caa8

Browse files
committed
Stub usePressabilityDebugStyle outside of DEV
1 parent 8fc1b64 commit 2e0caa8

1 file changed

Lines changed: 18 additions & 13 deletions

File tree

  • packages/react-native/Libraries/Text

‎packages/react-native/Libraries/Text/Text.js‎

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,24 @@ function useTextPressability({
466466
);
467467
}
468468

469+
function usePressabilityDebugStyleDev(
470+
style: ?TextStyleProp,
471+
onPress: ?(event: GestureResponderEvent) => unknown,
472+
): ?TextStyleProp {
473+
const isDebugEnabled = PressabilityDebug.useIsEnabled();
474+
return isDebugEnabled && onPress != null
475+
? [style, {color: 'magenta'}]
476+
: style;
477+
}
478+
479+
/**
480+
* Colors pressable text when press targets are shown by the Inspector.
481+
* Outside of `__DEV__` it returns the style unchanged and uses no hooks.
482+
*/
483+
const usePressabilityDebugStyle: typeof usePressabilityDebugStyleDev = __DEV__
484+
? usePressabilityDebugStyleDev
485+
: style => style;
486+
469487
/**
470488
* Wrap the NativeVirtualText component and initialize pressability.
471489
*
@@ -533,19 +551,6 @@ component PressableText(
533551
);
534552
}
535553

536-
/**
537-
* Colors pressable text when press targets are shown by the Inspector.
538-
*/
539-
function usePressabilityDebugStyle(
540-
style: NativeTextProps['style'],
541-
onPress: TextPressabilityProps['onPress'],
542-
): NativeTextProps['style'] {
543-
const isDebugEnabled = PressabilityDebug.useIsEnabled();
544-
return isDebugEnabled && onPress != null
545-
? [style, {color: 'magenta'}]
546-
: style;
547-
}
548-
549554
const userSelectToSelectableMap = {
550555
auto: true,
551556
text: true,

0 commit comments

Comments
 (0)