We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d3bdf8e commit ca71be9Copy full SHA for ca71be9
src/useImageDimensions.ts
@@ -36,15 +36,21 @@ function useImageDimensions(source: ImageRequireSource | URISource) {
36
}, [source])
37
38
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
+ dimensions:
+ dimensions &&
+ (Object.setPrototypeOf(dimensions, {
+ get aspectRatio(): number {
+ const _this = this as any
+ return _this.width / _this.height
+ },
+ }) as {
+ /**
48
+ * width to height ratio
49
+ */
50
+ readonly aspectRatio: number
51
+ width: number
52
+ height: number
53
+ }),
54
error,
55
get loading() {
56
return !dimensions && !error
0 commit comments