diff --git a/ios/extensions/UIResponder.swift b/ios/extensions/UIResponder.swift index 7f22ad1e39..8727b1d2b6 100644 --- a/ios/extensions/UIResponder.swift +++ b/ios/extensions/UIResponder.swift @@ -46,16 +46,13 @@ public extension Optional where Wrapped == UIResponder { } var nativeID: String? { + guard let superview = (self as? UIView)?.superview else { return nil } + #if KEYBOARD_CONTROLLER_NEW_ARCH_ENABLED - if let superview = (self as? UIView)?.superview as? NSObject { - return superview.value(forKey: "nativeId") as? String - } + return (superview as NSObject).value(forKey: "nativeId") as? String #else - if let superview = (self as? UIView)?.superview as? UIView { - return superview.nativeID as String? - } + return (superview as? UIView)?.nativeID #endif - return nil } }