Skip to content

Commit

Permalink
fix(hooks): arguments change error
Browse files Browse the repository at this point in the history
Fixes #6
  • Loading branch information
garthenweb committed Aug 20, 2019
1 parent 5a87c8f commit 0e036bb
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lib/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,11 @@ export const useViewportEffect = <T>(
hasRootProviderAsParent,
} = useContext(ViewportContext);

if (!hasRootProviderAsParent) {
warnNoContextAvailable('useViewport');
return;
}

useEffect(() => {
if (!hasRootProviderAsParent) {
warnNoContextAvailable('useViewport');
return;
}
addViewportChangeListener(handleViewportChange, {
notifyScroll: () => !options.disableScrollUpdates,
notifyDimensions: () => !options.disableDimensionsUpdates,
Expand All @@ -45,7 +44,7 @@ export const useViewportEffect = <T>(
recalculateLayoutBeforeUpdate: options.recalculateLayoutBeforeUpdate,
});
return () => removeViewportChangeListener(handleViewportChange);
}, [addViewportChangeListener, removeViewportChangeListener]);
}, [addViewportChangeListener || null, removeViewportChangeListener || null]);
};

export const useViewport = (options: IFullOptions = {}): IViewport => {
Expand Down

0 comments on commit 0e036bb

Please sign in to comment.