Skip to content

Commit 522e98b

Browse files
committed
fixing issue error could not be a a component constructor instead of rendered jsx
1 parent 5f61f87 commit 522e98b

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

src/react-image-zooom.tsx

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ interface ImageZoomProps {
9696
id?: string;
9797
className?: string;
9898
onError?: (error: ErrorEvent) => void;
99-
errorContent?: JSX.Element;
99+
errorContent?: JSX.Element | React.ReactNode;
100100
}
101101

102102
function ImageZoom({
@@ -225,16 +225,12 @@ function ImageZoom({
225225
[isZoomed, imgData, calculateZoom, position]
226226
);
227227

228-
if (error)
229-
return (
230-
<>
231-
{isValidElement(errorContent) ? (
232-
errorContent
233-
) : (
234-
<ErrorText>There was a problem loading your image</ErrorText>
235-
)}
236-
</>
237-
);
228+
if (error) {
229+
if (isValidElement(errorContent)) {
230+
return errorContent;
231+
}
232+
return <ErrorText>There was a problem loading your image</ErrorText>;
233+
}
238234

239235
const figureClasses = [
240236
imgData ? "loaded" : "loading",

0 commit comments

Comments
 (0)