11import React , { useEffect , useState } from 'react' ;
22import { FlatList , StyleSheet , Text , View } from 'react-native' ;
33import { Image , loadImageFromAssetAsync , NitroImage } from 'react-native-nitro-image' ;
4- import { CameraRoll } from " @react-native-camera-roll/camera-roll" ;
4+ import { CameraRoll } from ' @react-native-camera-roll/camera-roll' ;
55
66
77function useAssetImage (
88 url : string ,
99) : Image | undefined {
10- const [ image , setImage ] = useState < Image | undefined > ( undefined )
10+ const [ image , setImage ] = useState < Image | undefined > ( undefined ) ;
1111
1212 useEffect ( ( ) => {
1313 const load = async ( ) => {
1414 try {
15- const i = await loadImageFromAssetAsync ( url . replace ( / ^ p h : \/ \/ / , "" ) )
16- setImage ( i )
15+ const i = await loadImageFromAssetAsync ( url . replace ( / ^ p h : \/ \/ / , '' ) ) ;
16+ setImage ( i ) ;
1717 } catch ( error ) {
18- console . error ( `Failed to load image from "${ url } "!` , error )
19- setImage ( undefined )
18+ console . error ( `Failed to load image from "${ url } "!` , error ) ;
19+ setImage ( undefined ) ;
2020 }
21- }
22- load ( )
21+ } ;
22+ load ( ) ;
2323 // `options` is missing from dependencies since it's a reference type that will be constructed each render.
24- // eslint-disable-next-line react-hooks/exhaustive-deps
25- } , [ url ] )
2624
27- return image
25+ } , [ url ] ) ;
26+
27+ return image ;
2828}
2929function AsyncImageImpl ( { url } : { url : string } ) : React . ReactNode {
3030 const image = useAssetImage ( url ) ;
@@ -37,7 +37,7 @@ export function NitroAssetImageTab() {
3737
3838
3939 useEffect ( ( ) => {
40- CameraRoll . getPhotos ( { first : 100 , assetType : " Photos" } ) . then ( ( res ) => {
40+ CameraRoll . getPhotos ( { first : 100 , assetType : ' Photos' } ) . then ( ( res ) => {
4141 setImageURLs ( res . edges . map ( ( edge ) => edge . node . image . uri ) ) ;
4242 } ) ;
4343 } , [ ] ) ;
0 commit comments