fix: prevent exception when imageName is null (#20120)
Summary: When an image source is parsed via `RCTImageFromLocalAssetURL` there seem to be certain situations in which `imageName` is empty from `RCTBundlePathForURL`. Any call to `UIImage imageNamed` with a an empty parameter will throw an exception: ``` CUICatalog: Invalid asset name supplied: '(null)' ``` In my case, the asset URL was pointing to an image in the application sandbox rather than the `NSBundle`. In this case `UIImage imageNamed` was throwing before the call to `NSData dataWithContentsOfURL` below could correctly resolve the image. This change simply skips the call to `UIImage imageNamed` if no `imageName` value is set. Pull Request resolved: https://github.com/facebook/react-native/pull/20120 Differential Revision: D14163101 Pulled By: cpojer fbshipit-source-id: ceec95c02bf21b739962ef5618947a5726ba0473
This commit is contained in:
Родитель
30f13812ad
Коммит
bca85101cd
|
@ -700,10 +700,12 @@ UIImage *__nullable RCTImageFromLocalAssetURL(NSURL *imageURL)
|
|||
}
|
||||
|
||||
UIImage *image = nil;
|
||||
if (bundle) {
|
||||
image = [UIImage imageNamed:imageName inBundle:bundle compatibleWithTraitCollection:nil];
|
||||
} else {
|
||||
image = [UIImage imageNamed:imageName];
|
||||
if (imageName) {
|
||||
if (bundle) {
|
||||
image = [UIImage imageNamed:imageName inBundle:bundle compatibleWithTraitCollection:nil];
|
||||
} else {
|
||||
image = [UIImage imageNamed:imageName];
|
||||
}
|
||||
}
|
||||
|
||||
if (!image) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче