2023-01-31 14:41:21 +00:00
|
|
|
import useImgProxy from "Feed/ImgProxy";
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
2023-01-31 15:53:47 +00:00
|
|
|
export const ProxyImg = (props: any) => {
|
|
|
|
const { src, ...rest } = props;
|
2023-01-31 14:41:21 +00:00
|
|
|
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} />
|
|
|
|
}
|