Add lifecycle aware view managers to Example app

This commit is contained in:
Krzysztof Magiera
2018-09-05 09:01:57 +02:00
parent bd84706384
commit ccde895bdb
3 changed files with 37 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
#import <React/RCTViewManager.h>
@interface RNSLifecycleAwareView : UIView
@end
@implementation RNSLifecycleAwareView
- (void)didMoveToWindow
{
[super didMoveToWindow];
BOOL isVisible = self.superview && self.window;
if (isVisible) {
NSLog(@"ATTACHED");
} else {
NSLog(@"DETTACHED");
}
}
@end
@interface RNSLifecycleAwareViewManager : RCTViewManager
@end
@implementation RNSLifecycleAwareViewManager
RCT_EXPORT_MODULE()
- (UIView *)view
{
return [RNSLifecycleAwareView new];
}
@end