Skip to content

Commit ca71be9

Browse files
committed
[useImageDimensions] bug fix
1 parent d3bdf8e commit ca71be9

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

src/useImageDimensions.ts

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,21 @@ function useImageDimensions(source: ImageRequireSource | URISource) {
3636
}, [source])
3737

3838
return {
39-
dimensions: dimensions && {
40-
...dimensions,
41-
/**
42-
* width to height ratio
43-
*/
44-
get aspectRatio(): number {
45-
return this.width / this.height
46-
},
47-
},
39+
dimensions:
40+
dimensions &&
41+
(Object.setPrototypeOf(dimensions, {
42+
get aspectRatio(): number {
43+
const _this = this as any
44+
return _this.width / _this.height
45+
},
46+
}) as {
47+
/**
48+
* width to height ratio
49+
*/
50+
readonly aspectRatio: number
51+
width: number
52+
height: number
53+
}),
4854
error,
4955
get loading() {
5056
return !dimensions && !error

0 commit comments

Comments
 (0)