Skip to content

Commit eee4e85

Browse files
authored
Merge pull request #25 from Mario-Duarte/24-uncaught-error-objects-are-not-valid-as-a-react-child-found-object-with-keys-typeof-type-key-ref-props
24 - uncaught error objects are not valid as a react child found object with keys typeof type key ref props
2 parents dd67b9f + 2916993 commit eee4e85

File tree

6 files changed

+55
-47
lines changed

6 files changed

+55
-47
lines changed

lib/react-image-zooom.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { JSX } from "react";
1+
import React, { JSX } from "react";
22
interface ImageZoomProps {
33
zoom?: string | number;
44
fullWidth?: boolean;
@@ -9,7 +9,7 @@ interface ImageZoomProps {
99
id?: string;
1010
className?: string;
1111
onError?: (error: ErrorEvent) => void;
12-
errorContent?: JSX.Element;
12+
errorContent?: React.ReactNode;
1313
}
1414
declare function ImageZoom({ zoom, fullWidth, alt, width, height, src, id, className, onError, errorContent, }: ImageZoomProps): JSX.Element;
1515
export default ImageZoom;

lib/react-image-zooom.js

Lines changed: 7 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/react-image-zooom.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 37 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": {
55
"name": "Mario Duarte"
66
},
7-
"version": "1.5.5",
7+
"version": "1.5.6",
88
"main": "./lib/react-image-zooom.js",
99
"types": "./lib/react-image-zooom.d.ts",
1010
"module": "./lib/react-image-zooom.js",

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?: 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)