ai-tube / src /lib /hooks /useImageDimension.ts
jbilcke's picture
working to improve the clap format
f42b4a1
raw
history blame
468 Bytes
import { useEffect, useState } from "react"
import { ImageDimension, getImageDimension } from "../utils/getImageDimension"
export function useImageDimension(src: string) {
const [dimension, setDimension] = useState<ImageDimension>({
width: 0,
height: 0,
})
useEffect(() => {
const compute = async () => {
const newDimension = await getImageDimension(src)
setDimension(newDimension)
}
compute()
}, [src])
return dimension
}