mirror of
https://github.com/status-im/react-native.git
synced 2025-01-14 11:34:23 +00:00
Make resolveAssetSource public
Summary: When building a native component which takes an image reference as a prop, `resolveAssetSource` needs to be called on the image reference. If this isn't done, the native component may receive the opaque type returned by `require` (e.g. `require('./foo.png')`) which is useless to the native component. `resolveAssetSource` is used by builtin components that take image references such as `Image`, `WebView` and `MapView`. This change makes `resolveAssetSource` public so that third-party native components can correctly handle image references. **Test plan (required)** Verified that `Image.resolveAssetSource` works in a test app. Also, my team is using this change in our app. Adam Comella Microsoft Corp. Closes https://github.com/facebook/react-native/pull/10904 Differential Revision: D4177803 Pulled By: ericvicenti fbshipit-source-id: ffc511b9340325f7d1111002309cd8558ab8e6b0
This commit is contained in:
parent
7f6d435188
commit
fde7c35449
@ -220,7 +220,14 @@ var Image = React.createClass({
|
||||
*/
|
||||
async queryCache(urls: Array<string>): Promise<Map<string, 'memory' | 'disk'>> {
|
||||
return await ImageLoader.queryCache(urls);
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Resolves an asset reference into an object which has the properties `uri`, `width`,
|
||||
* and `height`. The input may either be a number (opaque type returned by
|
||||
* require('./foo.png')) or an `ImageSource` like { uri: '<http location || file path>' }
|
||||
*/
|
||||
resolveAssetSource: resolveAssetSource,
|
||||
},
|
||||
|
||||
mixins: [NativeMethodsMixin],
|
||||
|
@ -317,6 +317,12 @@ const Image = React.createClass({
|
||||
prefetch(url: string) {
|
||||
return ImageViewManager.prefetchImage(url);
|
||||
},
|
||||
/**
|
||||
* Resolves an asset reference into an object which has the properties `uri`, `width`,
|
||||
* and `height`. The input may either be a number (opaque type returned by
|
||||
* require('./foo.png')) or an `ImageSource` like { uri: '<http location || file path>' }
|
||||
*/
|
||||
resolveAssetSource: resolveAssetSource,
|
||||
},
|
||||
|
||||
mixins: [NativeMethodsMixin],
|
||||
|
Loading…
x
Reference in New Issue
Block a user