The onLoad event will be triggered once the image is loaded - https://idiallo.com/javascript/img-detect-loaded
NOTE - Do not conditionally render the img tag. The onLoad event will not be triggered if the img tag does not exist in the DOM. Rather, use the display property to set the loading state
Try this -
function Test() {
const [loading, setLoading] = useState(true);
return <>
<div style={{display: loading ? "block" : "none"}}>
{showLoader()}
</div>
<div style={{display: loading ? "none" : "block"}}>
<img
className="w-full"
src={item?.image}
onClick={() => setId(item?.id)}
onLoad={() => setLoading(false)} />
</div>
</>;
}