Add polyfill for ResizeObserver
This commit is contained in:
parent
c47eda8a0a
commit
a190eba006
2 changed files with 3 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
||||||
import { useEffect, useMemo, useState } from 'react';
|
import { useEffect, useMemo, useState } from 'react';
|
||||||
|
import ResizeObserver from 'resize-observer-polyfill';
|
||||||
|
|
||||||
type UseDimensionsRect = { width: number, height: number };
|
type UseDimensionsRect = { width: number, height: number };
|
||||||
type UseDimensionsResult = [Element | null, any, any]
|
type UseDimensionsResult = [Element | null, any, any]
|
||||||
|
@ -14,7 +15,7 @@ const useDimensions = (): UseDimensionsResult => {
|
||||||
|
|
||||||
const observer = useMemo(
|
const observer = useMemo(
|
||||||
() =>
|
() =>
|
||||||
new (window as any).ResizeObserver((entries: any) => {
|
new ResizeObserver((entries: any) => {
|
||||||
if (entries[0]) {
|
if (entries[0]) {
|
||||||
const { width, height } = entries[0].contentRect;
|
const { width, height } = entries[0].contentRect;
|
||||||
setRect({ width, height });
|
setRect({ width, height });
|
||||||
|
|
|
@ -181,6 +181,7 @@
|
||||||
"redux-thunk": "^2.2.0",
|
"redux-thunk": "^2.2.0",
|
||||||
"requestidlecallback": "^0.3.0",
|
"requestidlecallback": "^0.3.0",
|
||||||
"reselect": "^4.0.0",
|
"reselect": "^4.0.0",
|
||||||
|
"resize-observer-polyfill": "^1.5.1",
|
||||||
"sass": "^1.20.3",
|
"sass": "^1.20.3",
|
||||||
"sass-loader": "^13.0.0",
|
"sass-loader": "^13.0.0",
|
||||||
"semver": "^7.3.2",
|
"semver": "^7.3.2",
|
||||||
|
|
Loading…
Reference in a new issue