Skip to content

Commit

Permalink
fix: πŸ› make useMeasure work on server
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Feb 17, 2020
1 parent 3ca5251 commit 2daf769
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 2daf769

Please sign in to comment.