Add isPressable native prop to Text
Summary: react-native-windows currently needs to maintain a fork of TextNativeComponent to wire through a native-only prop for `isPressable`. The reason we do this on Windows is that we implement an optimization so we only attempt to hit test a virtual Text node if it is actually pressable, leading to significant perf improvement for pointer events (e.g., onMouseEnter / onMouseLeave) on Text. Changelog: [General][Added] - Native-only prop to optimize text hit testing on some RN platforms Reviewed By: JoshuaGross Differential Revision: D32564637 fbshipit-source-id: bf47c68d94a930d2c620cb3b1584355c5e412bd4
This commit is contained in:
Родитель
363ff5c0fc
Коммит
f3bf2e4f51
|
@ -163,6 +163,7 @@ const Text: React.AbstractComponent<
|
|||
{...restProps}
|
||||
{...eventHandlersForText}
|
||||
isHighlighted={isHighlighted}
|
||||
isPressable={isPressable}
|
||||
numberOfLines={numberOfLines}
|
||||
selectionColor={selectionColor}
|
||||
style={style}
|
||||
|
|
|
@ -19,6 +19,10 @@ type NativeTextProps = $ReadOnly<{
|
|||
...TextProps,
|
||||
isHighlighted?: ?boolean,
|
||||
selectionColor?: ?ProcessedColorValue,
|
||||
// This is only needed for platforms that optimize text hit testing, e.g.,
|
||||
// react-native-windows. It can be used to only hit test virtual text spans
|
||||
// that have pressable events attached to them.
|
||||
isPressable?: ?boolean,
|
||||
}>;
|
||||
|
||||
export const NativeText: HostComponent<NativeTextProps> =
|
||||
|
@ -26,6 +30,7 @@ export const NativeText: HostComponent<NativeTextProps> =
|
|||
validAttributes: {
|
||||
...ReactNativeViewAttributes.UIView,
|
||||
isHighlighted: true,
|
||||
isPressable: true,
|
||||
numberOfLines: true,
|
||||
ellipsizeMode: true,
|
||||
allowFontScaling: true,
|
||||
|
@ -59,6 +64,7 @@ export const NativeVirtualText: HostComponent<NativeTextProps> =
|
|||
validAttributes: {
|
||||
...ReactNativeViewAttributes.UIView,
|
||||
isHighlighted: true,
|
||||
isPressable: true,
|
||||
maxFontSizeMultiplier: true,
|
||||
},
|
||||
uiViewClassName: 'RCTVirtualText',
|
||||
|
|
Загрузка…
Ссылка в новой задаче