mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 11:34:23 +00:00
added didSetProps
for views and shadow views
Summary: Views and shadow views might want to configure themself once all of their props were set. So far there was no way to do it without writing some synchronization code. This diff adds a `didSetProps` call on both uiviews and shadow views, passing names of all props that were set for convenience. public Reviewed By: nicklockwood Differential Revision: D2699512 fb-gh-sync-id: 65f76e7bcbf5751d5b550261a953c463ed2f4e8a
This commit is contained in:
parent
2c0679bed1
commit
f86691a449
@ -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<NSString *> *)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.
|
||||
|
@ -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<NSString *, id> *)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];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user