From 2daf76990d0e1040f8c0f31e16e7c1eebd94c9bf Mon Sep 17 00:00:00 2001 From: streamich Date: Mon, 17 Feb 2020 22:42:07 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20make=20useMeasure=20work?= =?UTF-8?q?=20on=20server?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/useMeasure.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/useMeasure.ts b/src/useMeasure.ts index 57d5c6d3fb..f8d42766d7 100644 --- a/src/useMeasure.ts +++ b/src/useMeasure.ts @@ -1,5 +1,6 @@ import { useState, useMemo } from 'react'; import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect'; +import { isClient } from './util'; export type UseMeasureRect = Pick< DOMRectReadOnly, @@ -47,4 +48,4 @@ const useMeasure = (): UseMeasureResult => { const useMeasureMock = () => [() => {}, defaultState]; -export default !!(window as any).ResizeObserver ? useMeasure : useMeasureMock; +export default (isClient && !!(window as any).ResizeObserver) ? useMeasure : useMeasureMock;