Skip to content

Commit d40303c

Browse files
Saadnajmirozele
andauthored
Only apply isHighlighted native prop on iOS (facebook#38642) (#1893)
Summary: Pull Request resolved: facebook#38642 isHighlighted is only used for iOS. Even macOS disables it (see #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 Co-authored-by: Eric Rozell <[email protected]>
1 parent a0acbb7 commit d40303c

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Libraries/Text/Text.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ const Text: React.AbstractComponent<
108108
onLongPress,
109109
onPress,
110110
onPressIn(event: PressEvent) {
111-
setHighlighted(!suppressHighlighting);
111+
// Updating isHighlighted causes unnecessary re-renders for platforms that don't use it
112+
// in the best case, and cause issues with text selection in the worst case. Forcing
113+
// the isHighlighted prop to false on all platforms except iOS.
114+
setHighlighted(
115+
(suppressHighlighting == null || !suppressHighlighting) &&
116+
Platform.OS === 'ios',
117+
);
112118
onPressIn?.(event);
113119
},
114120
onPressOut(event: PressEvent) {

0 commit comments

Comments
 (0)