Skip to content

Commit 15667a3

Browse files
committed
feat: handle screenshot load error
1 parent ce637cc commit 15667a3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

  • packages/slice-machine/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal

packages/slice-machine/src/features/customTypes/customTypesBuilder/ImportSlicesFromLibraryModal/SliceCard.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Box, Checkbox, Text } from "@prismicio/editor-ui";
22
import { SharedSlice } from "@prismicio/types-internal/lib/customtypes";
3+
import { useState } from "react";
34

45
import { Card, CardFooter, CardMedia } from "@/components/Card";
56

@@ -12,15 +13,16 @@ interface SliceCardProps {
1213

1314
export function SliceCard(props: SliceCardProps) {
1415
const { thumbnailUrl, model, selected = true, onSelectedChange } = props;
16+
const [thumbnailError, setThumbnailError] = useState(false);
1517

1618
const handleClick = () => {
1719
onSelectedChange(!selected);
1820
};
1921

2022
const cardContent = (
2123
<>
22-
{thumbnailUrl !== undefined && thumbnailUrl ? (
23-
<CardMedia src={thumbnailUrl} />
24+
{thumbnailUrl !== undefined && thumbnailUrl && !thumbnailError ? (
25+
<CardMedia src={thumbnailUrl} onError={() => setThumbnailError(true)} />
2426
) : (
2527
<CardMedia component="div">
2628
<Box

0 commit comments

Comments
 (0)