Skip to content

Commit bcbebe3

Browse files
committed
refactor(cli): simplify ImageThumbnail state management
1 parent 06b1dc6 commit bcbebe3

File tree

1 file changed

+2
-13
lines changed

1 file changed

+2
-13
lines changed

cli/src/components/image-thumbnail.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,25 +33,14 @@ export const ImageThumbnail = memo(({
3333
fallback,
3434
}: ImageThumbnailProps) => {
3535
const [thumbnailData, setThumbnailData] = useState<ThumbnailData | null>(null)
36-
const [isLoading, setIsLoading] = useState(true)
37-
const [error, setError] = useState(false)
3836

3937
useEffect(() => {
4038
let cancelled = false
4139

4240
const loadThumbnail = async () => {
43-
setIsLoading(true)
44-
setError(false)
45-
4641
const data = await extractThumbnailColors(imagePath, width, height)
47-
4842
if (!cancelled) {
49-
if (data) {
50-
setThumbnailData(data)
51-
} else {
52-
setError(true)
53-
}
54-
setIsLoading(false)
43+
setThumbnailData(data)
5544
}
5645
}
5746

@@ -62,7 +51,7 @@ export const ImageThumbnail = memo(({
6251
}
6352
}, [imagePath, width, height])
6453

65-
if (isLoading || error || !thumbnailData) {
54+
if (!thumbnailData) {
6655
return <>{fallback}</>
6756
}
6857

0 commit comments

Comments
 (0)