Skip to content

Instantly share code, notes, and snippets.

@nkt
Created December 23, 2017 01:46
Show Gist options
  • Save nkt/a50728d891babaeadd57cd04b7b63cf5 to your computer and use it in GitHub Desktop.
Save nkt/a50728d891babaeadd57cd04b7b63cf5 to your computer and use it in GitHub Desktop.

React Native Swift

Example of react native swift component implementation

#import <React/RCTBridgeModule.h>
#import <React/RCTViewManager.h>
@interface RCT_EXTERN_MODULE(RNPhoneInputSwift, RCTViewManager)
RCT_EXPORT_VIEW_PROPERTY(value, NSString);
@end
import Foundation
@objc(RNPhoneInput)
public class RNPhoneInput : UITextField {
@objc(setValue:)
public func setValue(value: String) {
self.text = value
}
}
import Foundation
@objc(RNPhoneInputSwift)
class RNPhoneInputManager : RCTViewManager {
override static func requiresMainQueueSetup() -> Bool {
return false
}
override func view() -> UIView! {
return RNPhoneInput()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment