17 lines
339 B
JavaScript
17 lines
339 B
JavaScript
|
|
||
|
// @flow
|
||
|
|
||
|
import { Image } from 'react-native';
|
||
|
|
||
|
/**
|
||
|
* Tries to preload an image.
|
||
|
*
|
||
|
* @param {string} src - Source of the avatar.
|
||
|
* @returns {Promise}
|
||
|
*/
|
||
|
export function preloadImage(src: string): Promise<string> {
|
||
|
return new Promise((resolve, reject) => {
|
||
|
Image.prefetch(src).then(() => resolve(src), reject);
|
||
|
});
|
||
|
}
|