import React from 'react'; import { PngDiffDataZone, PageData } from 'test-crawler-core'; import { imgStyle, } from '../pages/pageStyle'; import { DiffZone } from './DiffZone'; import { Props as DiffImageProps, DiffImage } from './DiffImage'; import { useAsyncCacheWatch } from 'react-async-cache'; import { getThumbnail } from '../server/service'; interface Props { zones?: PngDiffDataZone[]; originalWidth?: number; setPages: React.Dispatch>; }; export const DiffImageWithZone = ({ storageType, projectId, timestamp, id, zones, originalWidth = 0, width = imgStyle.width, setPages, marginLeft, ...props }: Props & DiffImageProps) => { // we might not even need useAsyncCacheWatch const { call, response: thumb, cache } = useAsyncCacheWatch(getThumbnail, storageType, projectId, 'pin', id, width); React.useEffect(() => { if (zones && !cache()) { call(); } }, [zones]); return ( {zones?.map(({ zone, status }: PngDiffDataZone, index: number) => ) } ); };