mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Only apply isHighlighted native prop on iOS (#38642)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/38642 isHighlighted is only used for iOS. Even macOS disables it (see https://github.com/microsoft/react-native-macos/pull/1346). This change ensures that the isHighlighted prop is only updated for iOS. ## Changelog: [General] [Fixed] - Avoids re-renders during text selection on desktop platforms by limiting native-only `isHighlighted` prop to iOS Reviewed By: lenaic, sammy-SC Differential Revision: D47800845 fbshipit-source-id: af109be17027b2fbc9408e2ec9e1b841c709fe35
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6cd1da94b8
commit
3d2fd4bf22
+7
-1
@@ -105,7 +105,13 @@ const Text: React.AbstractComponent<
|
||||
onLongPress,
|
||||
onPress,
|
||||
onPressIn(event: PressEvent) {
|
||||
setHighlighted(!suppressHighlighting);
|
||||
// Updating isHighlighted causes unnecessary re-renders for platforms that don't use it
|
||||
// in the best case, and cause issues with text selection in the worst case. Forcing
|
||||
// the isHighlighted prop to false on all platforms except iOS.
|
||||
setHighlighted(
|
||||
(suppressHighlighting == null || !suppressHighlighting) &&
|
||||
Platform.OS === 'ios',
|
||||
);
|
||||
onPressIn?.(event);
|
||||
},
|
||||
onPressOut(event: PressEvent) {
|
||||
|
||||
Reference in New Issue
Block a user