diff --git a/src/components/AutoImage.jsx b/src/components/AutoImage.jsx index abb6276..44db993 100644 --- a/src/components/AutoImage.jsx +++ b/src/components/AutoImage.jsx @@ -1,8 +1,17 @@ import * as React from 'react'; import { Image } from 'react-native'; -const AutoImage = ({ src, fitWidth = 0, token, style = {} }) => { - const [aspect, setAspect] = React.useState(0); - return ( +const AutoImage = ({ + src, + fitWidth = 0, + srcWidth, + srcHeight, + token, + style = {}, +}) => { + const aspect = React.useMemo(() => { + return srcHeight / srcWidth; + }, []); + return React.useCallback( { width: fitWidth, height: fitWidth * aspect, borderRadius: 7, - marginBottom: 5, ...style, }} resizeMode="cover" - onLoad={({ - nativeEvent: { - source: { width, height }, - }, - }) => { - setAspect(height / width); - }} - /> + />, + [], ); }; diff --git a/src/components/AutoVideo.jsx b/src/components/AutoVideo.jsx index 43ae778..780f75d 100644 --- a/src/components/AutoVideo.jsx +++ b/src/components/AutoVideo.jsx @@ -9,6 +9,7 @@ const AutoVideo = ({ token, style = {}, poster, + format, }) => { const aspect = React.useMemo(() => { return srcHeight / srcWidth; @@ -16,12 +17,12 @@ const AutoVideo = ({ return React.useCallback(