diff --git a/React/Views/RCTComponent.h b/React/Views/RCTComponent.h index 2940b4311..5236f850b 100644 --- a/React/Views/RCTComponent.h +++ b/React/Views/RCTComponent.h @@ -36,6 +36,13 @@ typedef void (^RCTBubblingEventBlock)(NSDictionary *body); @optional +/** + * Called each time props have been set. + * Not all props have to be set - React can set only changed ones. + * @param changedProps String names of all set props. + */ +- (void)didSetProps:(NSArray *)changedProps; + // TODO: Deprecate this // This method is called after layout has been performed for all views known // to the RCTViewManager. It is only called on UIViews, not shadow views. diff --git a/React/Views/RCTComponentData.m b/React/Views/RCTComponentData.m index dbcbc10c9..8aa82bf28 100644 --- a/React/Views/RCTComponentData.m +++ b/React/Views/RCTComponentData.m @@ -302,6 +302,10 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) [props enumerateKeysAndObjectsUsingBlock:^(NSString *key, id json, __unused BOOL *stop) { [self propBlockForKey:key defaultView:_defaultView](view, json); }]; + + if ([view respondsToSelector:@selector(didSetProps:)]) { + [view didSetProps:[props allKeys]]; + } } - (void)setProps:(NSDictionary *)props forShadowView:(RCTShadowView *)shadowView @@ -318,6 +322,9 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init) [self propBlockForKey:key defaultView:_defaultShadowView](shadowView, json); }]; + if ([shadowView respondsToSelector:@selector(didSetProps:)]) { + [shadowView didSetProps:[props allKeys]]; + } [shadowView updateLayout]; }