I’m building an imageFallback to use in a react remix website. I’m trying to convert it from js to ts. Here is the js version.
export default function ImageFallback({
src,
fallback,
type = "image/webp",
...delegated
}) {
return (
<picture>
<source srcSet={src} type={type} />
<img src={fallback} {...delegated} />
</picture>
);
}
My ts version gets the error ‘Type ‘{ src: string; }’ is not assignable to type ‘ReactNode’.ts(2322)’
What is a better way to write this? Here is my ts version.
import type { FC } from "react";
interface ImageFallbackProps {
src: string;
fallback: string;
type?: string;
alt?: string;
[key: string]: any;
}
const ImageFallback: FC<ImageFallbackProps> = ({
src,
fallback,
type = "image/webp",
alt = "",
...delegated
}) => (
<picture>
<source srcSet={src} type={type} />
<img src={fallback} alt={alt} {...delegated} />
</picture>
);
export default ImageFallback;
Thanks for the help in advance.