import React, {useEffect, useState} from 'react' import {Image} from 'react-native' export type ScaledImageProps = { uri: string width?: string | number height?: number | string } type State = { width?: number | string height?: number | string aspectRatio: string } export const ScaledImage: React.FC = ({ uri, width: propsWidth, height: propsHeight, }) => { const [size, setSize] = useState({ width: undefined, height: undefined, aspectRatio: '1', }) useEffect(() => { Image.getSize(uri, (width, height) => { setSize({ width: propsWidth, height: propsHeight, aspectRatio: `${width} / ${height}`, }) }) }, []) return }