Skip to content

Commit

Permalink
fix(useSize): possible ReferenceError caused by accessing ResizeObserver
Browse files Browse the repository at this point in the history
  • Loading branch information
kripod committed Oct 25, 2019
1 parent 906725a commit b708153
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/web-api-hooks/src/useSize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export default function useSize(
const [size, setSize] = useState<Readonly<[number, number]>>([0, 0]);

useEffect(() => {
const CustomResizeObserver = ResizeObserverOverride || ResizeObserver;
if (!CustomResizeObserver || !ref.current) return undefined;
const ResizeObserver = ResizeObserverOverride || window.ResizeObserver;
if (!ResizeObserver || !ref.current) return undefined;

const observer = new CustomResizeObserver(([entry]) => {
const observer = new ResizeObserver(([entry]) => {
const { width, height } = entry.contentRect;
setSize([width, height]);
});
Expand Down

0 comments on commit b708153

Please sign in to comment.