diff --git a/src/index.tsx b/src/index.tsx index 81ce883..63fd55d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4,20 +4,18 @@ import React from "react"; export type NextImageFromFileProps = Partial & Pick; -function isImageProps(props: NextImageFromFileProps): props is ImageProps { - return typeof props.src !== "string" || !!(props.width && props.height); -} - export default function NextImageFromFile(props: NextImageFromFileProps) { const [image, setImage] = React.useState(null); - if (isImageProps(props)) { + // Fall back to regular next/image if all necessary props are given + if (typeof props.src !== "string" || (props.width && props.height)) { return ; } + // No width and height available? Render raw img tag first to figure them out if (!image) return ( ); + // Width and height have been figured out, render the next/image return (