diff --git a/ios/Elements/RNSVGForeignObject.h b/ios/Elements/RNSVGForeignObject.h index 346b204c..c3f793ff 100644 --- a/ios/Elements/RNSVGForeignObject.h +++ b/ios/Elements/RNSVGForeignObject.h @@ -1,9 +1,11 @@ #import "RNSVGGroup.h" #import "RNSVGLength.h" +#import "RCTEventDispatcher.h" @interface RNSVGForeignObject : RNSVGGroup +- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher; @property (nonatomic, strong) RNSVGLength *x; @property (nonatomic, strong) RNSVGLength *y; @property (nonatomic, strong) RNSVGLength *foreignObjectwidth; diff --git a/ios/Elements/RNSVGForeignObject.m b/ios/Elements/RNSVGForeignObject.m index e2a7b80d..2083b6c2 100644 --- a/ios/Elements/RNSVGForeignObject.m +++ b/ios/Elements/RNSVGForeignObject.m @@ -7,19 +7,45 @@ */ #import "RNSVGForeignObject.h" #import "RNSVGNode.h" +#import "RCTUIManager.h" +#import "RCTUIManagerObserverCoordinator.h" @implementation RNSVGForeignObject +{ + RCTEventDispatcher *_eventDispatcher; + bool _ready; +} - (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { return nil; } +- (instancetype)initWithEventDispatcher:(RCTEventDispatcher *)eventDispatcher +{ + RCTAssertParam(eventDispatcher); + + if ((self = [super init])) { + _eventDispatcher = eventDispatcher; + [_eventDispatcher.bridge.uiManager.observerCoordinator addObserver:self]; + } + return self; +} + - (void)parseReference { self.dirty = false; } +- (void)uiManagerDidPerformMounting:(RCTUIManager *)manager +{ + [manager addUIBlock:^(__unused RCTUIManager *uiManager, __unused NSDictionary *viewRegistry) { + if (!self->_ready && !self.dirty) { + [self invalidate]; + } + }]; +} + - (void)renderLayerTo:(CGContextRef)context rect:(CGRect)rect { [self clip:context]; diff --git a/ios/ViewManagers/RNSVGForeignObjectManager.m b/ios/ViewManagers/RNSVGForeignObjectManager.m index c7acbec1..58841fb4 100644 --- a/ios/ViewManagers/RNSVGForeignObjectManager.m +++ b/ios/ViewManagers/RNSVGForeignObjectManager.m @@ -15,7 +15,7 @@ RCT_EXPORT_MODULE() - (RNSVGForeignObject *)node { - return [RNSVGForeignObject new]; + return [[RNSVGForeignObject alloc] initWithEventDispatcher:self.bridge.eventDispatcher]; } RCT_EXPORT_VIEW_PROPERTY(x, RNSVGLength*)