mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-24 12:25:59 +08:00
Removed placeholder image logic
Summary: To prevent layout popping, when inserting images inside text we would render a blank placeholder image while the real image was loading. It turns out that this isn't necessary, as we can just specify the size of the image without having an actual image to display. Reviewed By: javache Differential Revision: D3212766 fb-gh-sync-id: e98851b32a2d0ae809fc0a4be47e6b77f3b17996 fbshipit-source-id: e98851b32a2d0ae809fc0a4be47e6b77f3b17996
This commit is contained in:
committed by
Facebook Github Bot 2
parent
0bf737ff0a
commit
37f4ec6e16
@@ -217,12 +217,10 @@ static css_dim_t RCTMeasure(void *context, float width, css_measure_mode_t width
|
||||
RCTShadowRawText *shadowRawText = (RCTShadowRawText *)child;
|
||||
[attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:shadowRawText.text ?: @""]];
|
||||
} else if ([child conformsToProtocol:@protocol(RCTImageComponent)]) {
|
||||
UIImage *image = ((id<RCTImageComponent>)child).image;
|
||||
if (image) {
|
||||
NSTextAttachment *imageAttachment = [NSTextAttachment new];
|
||||
imageAttachment.image = image;
|
||||
[attributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:imageAttachment]];
|
||||
}
|
||||
NSTextAttachment *imageAttachment = [NSTextAttachment new];
|
||||
imageAttachment.image = ((id<RCTImageComponent>)child).image;
|
||||
imageAttachment.bounds = (CGRect){CGPointZero, {RCTZeroIfNaN(child.width), RCTZeroIfNaN(child.height)}};
|
||||
[attributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:imageAttachment]];
|
||||
} else {
|
||||
RCTLogError(@"<Text> can't have any children except <Text>, <Image> or raw strings");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user