mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-03-26 07:04:05 +08:00
Unify XCAsset handling logic
Summary: @public This diff unifies the logic for detecting when images refer to XCAsset files into a single function (RCTXCAssetNameForURL) and uses it for both +[RCTConvert UIImage:] and RCTImageLoader. I've also tightened the definition of XCAssets so that it only applies to images inside .car files, not any image inside the main bundle. This avoids using the +[UIImage imageNamed:] when not strictly necessary, which is desirable since that method is not thread-safe, and has undocumented caching behavior that is difficult to reason about. Reviewed By: @javache Differential Revision: D2526400 fb-gh-sync-id: 7199c2a44f1d55ff236d2c38a0a9368739b993d5
This commit is contained in:
committed by
facebook-github-bot-4
parent
c16c3f9814
commit
799168929c
@@ -47,7 +47,12 @@ RCT_EXPORT_MODULE()
|
||||
|
||||
- (BOOL)canHandleRequest:(NSURLRequest *)request
|
||||
{
|
||||
return [@[@"http", @"https", @"file"] containsObject:request.URL.scheme.lowercaseString];
|
||||
static NSSet *schemes = nil;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
schemes = [[NSSet alloc] initWithObjects:@"http", @"https", @"file", nil];
|
||||
});
|
||||
return [schemes containsObject:request.URL.scheme.lowercaseString];
|
||||
}
|
||||
|
||||
- (NSURLSessionDataTask *)sendRequest:(NSURLRequest *)request
|
||||
|
||||
Reference in New Issue
Block a user