17 lines
443 B
TypeScript
17 lines
443 B
TypeScript
|
import useImgProxy from "Feed/ImgProxy";
|
||
|
import { useEffect, useState } from "react";
|
||
|
|
||
|
export const ProxyImg = ({ src, ...rest }: { src?: string }) => {
|
||
|
const [url, setUrl] = useState<string>();
|
||
|
const { proxy } = useImgProxy();
|
||
|
|
||
|
useEffect(() => {
|
||
|
if (src) {
|
||
|
proxy(src)
|
||
|
.then(a => setUrl(a))
|
||
|
.catch(console.warn);
|
||
|
}
|
||
|
}, [src]);
|
||
|
|
||
|
return <img src={url} {...rest} />
|
||
|
}
|