Permalink
Browse files

Using <Image> with nested content now causes warning (yellowbox)

Summary:
We are removing support of nesting views inside <Image> component. We decided to do this because having this feature makes supporting intrinsinc content size of the <Image> impossible; so when the transition process is complete, there will be no need to specify image size explicitly, it can be inferred from actual image bitmap.

And this is the step #2: Yellow Box.

<ImageBackground> is very simple drop-in replacement which implements this functionality via very simple styling.
Please, use <ImageBackground> instead of <Image> if you want to put something inside.

Reviewed By: yungsters

Differential Revision: D5139264

fbshipit-source-id: 99442107e10a321618fd34802c57a8c205ce66fb
  • Loading branch information...
shergin authored and facebook-github-bot committed May 31, 2017
1 parent adaf2bf commit 279f5f1c56ce0b31556ff08a55f11344694c8e7f
@@ -51,6 +51,8 @@
3DED3A9E1DE6F7A400336DD7 /* RCTImageViewManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 1304D5A91AA8C4A30002E2BE /* RCTImageViewManager.h */; };
3DED3A9F1DE6F7A400336DD7 /* RCTLocalAssetImageLoader.h in Headers */ = {isa = PBXBuildFile; fileRef = 13EF7F7D1BC825B1003F47DD /* RCTLocalAssetImageLoader.h */; };
3DED3AA01DE6F7A400336DD7 /* RCTResizeMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 3D5FA63E1DE4B44A0058FD77 /* RCTResizeMode.h */; };
59AB092A1EDE5DD1009F97B5 /* RCTImageShadowView.h in Headers */ = {isa = PBXBuildFile; fileRef = 59AB09281EDE5DD1009F97B5 /* RCTImageShadowView.h */; };
59AB092B1EDE5DD1009F97B5 /* RCTImageShadowView.m in Sources */ = {isa = PBXBuildFile; fileRef = 59AB09291EDE5DD1009F97B5 /* RCTImageShadowView.m */; };
CCD34C271D4B8FE900268922 /* RCTImageCache.m in Sources */ = {isa = PBXBuildFile; fileRef = CCD34C261D4B8FE900268922 /* RCTImageCache.m */; };
EEF314721C9B0DD30049118E /* RCTImageBlurUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = EEF314711C9B0DD30049118E /* RCTImageBlurUtils.m */; };
/* End PBXBuildFile section */
@@ -102,6 +104,8 @@
3D5FA63E1DE4B44A0058FD77 /* RCTResizeMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTResizeMode.h; sourceTree = "<group>"; };
3D5FA68C1DE4BA290058FD77 /* libRCTNetwork.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libRCTNetwork.a; path = "../Network/build/Debug-iphoneos/libRCTNetwork.a"; sourceTree = "<group>"; };
58B5115D1A9E6B3D00147676 /* libRCTImage.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTImage.a; sourceTree = BUILT_PRODUCTS_DIR; };
59AB09281EDE5DD1009F97B5 /* RCTImageShadowView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTImageShadowView.h; sourceTree = "<group>"; };
59AB09291EDE5DD1009F97B5 /* RCTImageShadowView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageShadowView.m; sourceTree = "<group>"; };
CCD34C251D4B8FE900268922 /* RCTImageCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RCTImageCache.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
CCD34C261D4B8FE900268922 /* RCTImageCache.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageCache.m; sourceTree = "<group>"; };
EEF314701C9B0DD30049118E /* RCTImageBlurUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RCTImageBlurUtils.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
@@ -120,6 +124,8 @@
58B511541A9E6B3D00147676 = {
isa = PBXGroup;
children = (
3D5FA68B1DE4BA290058FD77 /* Frameworks */,
58B5115E1A9E6B3D00147676 /* Products */,
1304D5B01AA8C50D0002E2BE /* RCTGIFImageDecoder.h */,
1304D5B11AA8C50D0002E2BE /* RCTGIFImageDecoder.m */,
EEF314701C9B0DD30049118E /* RCTImageBlurUtils.h */,
@@ -130,6 +136,8 @@
354631671B69857700AA0B86 /* RCTImageEditingManager.m */,
3D5FA63C1DE4B44A0058FD77 /* RCTImageLoader.h */,
143879371AAD32A300F088A5 /* RCTImageLoader.m */,
59AB09281EDE5DD1009F97B5 /* RCTImageShadowView.h */,
59AB09291EDE5DD1009F97B5 /* RCTImageShadowView.m */,
3D5FA63D1DE4B44A0058FD77 /* RCTImageStoreManager.h */,
35123E6A1B59C99D00EBAD80 /* RCTImageStoreManager.m */,
134B00A01B54232B00EC8DFB /* RCTImageUtils.h */,
@@ -142,8 +150,6 @@
13EF7F7E1BC825B1003F47DD /* RCTLocalAssetImageLoader.m */,
3D5FA63E1DE4B44A0058FD77 /* RCTResizeMode.h */,
139A38831C4D587C00862840 /* RCTResizeMode.m */,
58B5115E1A9E6B3D00147676 /* Products */,
3D5FA68B1DE4BA290058FD77 /* Frameworks */,
);
indentWidth = 2;
sourceTree = "<group>";
@@ -172,6 +178,7 @@
3DED3A8D1DE6F79800336DD7 /* RCTImageEditingManager.h in Headers */,
3DED3A8E1DE6F79800336DD7 /* RCTImageLoader.h in Headers */,
3DED3A8F1DE6F79800336DD7 /* RCTImageStoreManager.h in Headers */,
59AB092A1EDE5DD1009F97B5 /* RCTImageShadowView.h in Headers */,
3DED3A911DE6F79800336DD7 /* RCTImageView.h in Headers */,
3DED3A921DE6F79800336DD7 /* RCTImageViewManager.h in Headers */,
3DED3A931DE6F79800336DD7 /* RCTLocalAssetImageLoader.h in Headers */,
@@ -301,6 +308,7 @@
139A38841C4D587C00862840 /* RCTResizeMode.m in Sources */,
1304D5AB1AA8C4A30002E2BE /* RCTImageView.m in Sources */,
EEF314721C9B0DD30049118E /* RCTImageBlurUtils.m in Sources */,
59AB092B1EDE5DD1009F97B5 /* RCTImageShadowView.m in Sources */,
13EF7F7F1BC825B1003F47DD /* RCTLocalAssetImageLoader.m in Sources */,
134B00A21B54232B00EC8DFB /* RCTImageUtils.m in Sources */,
CCD34C271D4B8FE900268922 /* RCTImageCache.m in Sources */,
@@ -0,0 +1,14 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import <React/RCTShadowView.h>
@interface RCTImageShadowView : RCTShadowView
@end
@@ -0,0 +1,25 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#import "RCTImageShadowView.h"
#import <React/RCTLog.h>
@implementation RCTImageShadowView
- (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex
{
RCTLogWarn(@"Using <Image> with children is deprecated "
"and will be an error in the near future. "
"Please reconsider the layout or use <ImageBackground> instead.");
[super insertReactSubview:subview atIndex:atIndex];
}
@end
@@ -14,12 +14,18 @@
#import <React/RCTConvert.h>
#import "RCTImageLoader.h"
#import "RCTImageShadowView.h"
#import "RCTImageView.h"
@implementation RCTImageViewManager
RCT_EXPORT_MODULE()
- (RCTShadowView *)shadowView
{
return [RCTImageShadowView new];
}
- (UIView *)view
{
return [[RCTImageView alloc] initWithBridge:self.bridge];

0 comments on commit 279f5f1

Please sign in to comment.