( image: ImageSourcePropType, )
| 1 | import {Image, type ImageSourcePropType} from 'react-native'; |
| 2 | |
| 3 | export function fixImageProp( |
| 4 | image: ImageSourcePropType, |
| 5 | ): {uri: string} | ImageSourcePropType { |
| 6 | if (typeof image === 'string') { |
| 7 | return {uri: image}; |
| 8 | } |
| 9 | |
| 10 | if (typeof image === 'number') { |
| 11 | // Handle local image asset (require('./image.png')) |
| 12 | const resolvedImage = Image.resolveAssetSource(image); |
| 13 | return resolvedImage?.uri ? {uri: resolvedImage.uri} : image; |
| 14 | } |
| 15 | |
| 16 | return image; |
| 17 | } |