From 340b84f053d48e45a5e4e9648ac4f87fc00e5f4a Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 17 Jan 2024 11:17:36 -0800 Subject: [PATCH] handle prop changes for both children and root views --- modules/expo-selectable-text/ios/ExpoUITextView.swift | 8 +++++--- .../expo-selectable-text/ios/ExpoUITextViewChild.swift | 5 +++++ .../expo-selectable-text/ios/ExpoUITextViewModule.swift | 4 ---- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/expo-selectable-text/ios/ExpoUITextView.swift b/modules/expo-selectable-text/ios/ExpoUITextView.swift index a428985c43..b80138cc5e 100644 --- a/modules/expo-selectable-text/ios/ExpoUITextView.swift +++ b/modules/expo-selectable-text/ios/ExpoUITextView.swift @@ -54,9 +54,11 @@ class ExpoUITextView: ExpoView { // Do the same whenever subviews are removed override func removeReactSubview(_ subview: UIView!) { - if subview.isKind(of: ExpoUITextViewChild.self) { - subview.removeFromSuperview() - } + subview.removeFromSuperview() + } + + override func didSetProps(_ changedProps: [String]!) { + self.getTextChildren() } // Just return the subviews diff --git a/modules/expo-selectable-text/ios/ExpoUITextViewChild.swift b/modules/expo-selectable-text/ios/ExpoUITextViewChild.swift index d24c5b46b1..3ad5b058ed 100644 --- a/modules/expo-selectable-text/ios/ExpoUITextViewChild.swift +++ b/modules/expo-selectable-text/ios/ExpoUITextViewChild.swift @@ -4,4 +4,9 @@ class ExpoUITextViewChild: ExpoView { var text: String? var style: TextStyle? let onTextPress = EventDispatcher() + + override func didSetProps(_ changedProps: [String]!) { + let superview = self.superview as? ExpoUITextView + superview?.setText() + } } diff --git a/modules/expo-selectable-text/ios/ExpoUITextViewModule.swift b/modules/expo-selectable-text/ios/ExpoUITextViewModule.swift index e5030a1ccf..dd9532147f 100644 --- a/modules/expo-selectable-text/ios/ExpoUITextViewModule.swift +++ b/modules/expo-selectable-text/ios/ExpoUITextViewModule.swift @@ -36,10 +36,6 @@ public class ExpoUITextViewModule: Module { } Prop("numberOfLines") { (view: ExpoUITextView, prop: Int?) in view.textView.textContainer.maximumNumberOfLines = prop ?? 0 - - if view.textView.attributedText != nil { - view.setText() - } } Prop("ellipsizeMode") { (view: ExpoUITextView, prop: EllipsizeMode) in view.textView.textContainer.lineBreakMode = prop.toLineBreakMode()