Skip to content

Commit

Permalink
fix: πŸ› correctly test if env is browser in useMeasure
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed May 16, 2020
1 parent dc92b64 commit 9ae494f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/useMeasure.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { useState, useMemo } from 'react';
import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';
import { isClient } from './util';

export type UseMeasureRect = Pick<
DOMRectReadOnly,
Expand Down Expand Up @@ -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;

0 comments on commit 9ae494f

Please sign in to comment.