Move RCTImageLoader asserts to protect bridge usage

Summary:
`RCTImageLoader ` needs loaders & decoders. These can be passed in through init, or looked up at runtime using the bridge. In bridgeless mode, we need to pass them in through init.

This diff just moves the assert to actually protect `_bridge` usage, since there exist other codepaths which don't use the bridge.

Changelog: [iOS][Internal] Move RCTImageLoader asserts to protect bridge usage

Reviewed By: RSNara

Differential Revision: D18990760

fbshipit-source-id: 285008e7b3f473c45381ab472c3d86e5d8e218ae
This commit is contained in:
Peter Argany
2019-12-16 16:41:20 -08:00
committed by Facebook Github Bot
parent 6ceef13a9c
commit c7f7b4c87a
+2 -2
View File
@@ -169,11 +169,11 @@ RCT_EXPORT_MODULE()
if (!_loaders) {
// Get loaders, sorted in reverse priority order (highest priority first)
RCTAssert(_bridge, @"Bridge not set");
if (_loadersProvider) {
_loaders = _loadersProvider();
} else {
RCTAssert(_bridge, @"Trying to find RCTImageURLLoaders and bridge not set.");
_loaders = [_bridge modulesConformingToProtocol:@protocol(RCTImageURLLoader)];
}
@@ -233,11 +233,11 @@ RCT_EXPORT_MODULE()
if (!_decoders) {
// Get decoders, sorted in reverse priority order (highest priority first)
RCTAssert(_bridge, @"Bridge not set");
if (_decodersProvider) {
_decoders = _decodersProvider();
} else {
RCTAssert(_bridge, @"Trying to find RCTImageDataDecoders and bridge not set.");
_decoders = [_bridge modulesConformingToProtocol:@protocol(RCTImageDataDecoder)];
}