Commit 724f942d authored by Phạm Quang Bảo's avatar Phạm Quang Bảo

update/image next

parent 715302d6
import Image from "next/image";
import { useState } from "react";
import { useEffect, useState } from "react";
const ImageNext = ({ src, alt, width, height, className, onError }: any) => {
const ImageNext = ({ src, alt, width, height, className, fallback = "/img-error.png" }: any) => {
const [imgSrc, setImgSrc] = useState(src);
useEffect(() => {
setImgSrc(src);
}, [src]);
return (
<Image
src={imgSrc}
......@@ -11,7 +15,7 @@ const ImageNext = ({ src, alt, width, height, className, onError }: any) => {
width={width}
height={height}
className={className}
onError={() => setImgSrc(onError || "/img-error.png")}
onError={() => setImgSrc(fallback)}
unoptimized
/>
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment