about summary refs log tree commit diff
path: root/src/view/com/lightbox/ImageViewing/hooks/useImagePrefetch.ts
blob: 3969945bb58845577046b80ff796a79470723fb9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
 * Copyright (c) JOB TODAY S.A. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 *
 */

import {useEffect} from 'react'
import {Image} from 'react-native'
import {ImageSource} from '../@types'

const useImagePrefetch = (images: ImageSource[]) => {
  useEffect(() => {
    images.forEach(image => {
      //@ts-ignore
      if (image.uri) {
        //@ts-ignore
        return Image.prefetch(image.uri)
      }
    })
  }, [images])
}

export default useImagePrefetch