您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

preloadImage.native.ts 641B

1234567891011121314151617181920212223242526
  1. import { Image } from 'react-native';
  2. import { isIconUrl } from './functions';
  3. /**
  4. * Tries to preload an image.
  5. *
  6. * @param {string | Object} src - Source of the avatar.
  7. * @param {boolean} _isUsingCORS - Used on web.
  8. * @returns {Promise}
  9. */
  10. export function preloadImage(src: string | Object, _isUsingCORS: boolean): Promise<any> {
  11. if (isIconUrl(src)) {
  12. return Promise.resolve(src);
  13. }
  14. return new Promise((resolve, reject) => {
  15. // @ts-ignore
  16. Image.prefetch(src).then(
  17. () => resolve({
  18. src,
  19. isUsingCORS: false
  20. }),
  21. reject);
  22. });
  23. }