From cbf6f3a63487b134218f8a374d1d982c7a8d08f0 Mon Sep 17 00:00:00 2001 From: Viktor Vincze Date: Fri, 15 May 2020 23:28:22 +0200 Subject: [PATCH] fix: missing dependencies --- src/story.tsx | 2 ++ src/useBreakpoint.ts | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/story.tsx b/src/story.tsx index 83a63ca..9ad7b1f 100644 --- a/src/story.tsx +++ b/src/story.tsx @@ -22,6 +22,8 @@ storiesOf('Hooks|useBreakpoint', module).add( ['large', 'is large'] ]) + console.log(useBreakpoint()) + return
Example code
{`const value = useBreakpoint('none', [
diff --git a/src/useBreakpoint.ts b/src/useBreakpoint.ts
index a884642..2f173de 100644
--- a/src/useBreakpoint.ts
+++ b/src/useBreakpoint.ts
@@ -67,13 +67,13 @@ let cachedIh = getInnerHeight()
 export function useBreakpoint(defaultValue: any, breakpointValues: any[]): any
 export function useBreakpoint(): { [key: string]: boolean }
 export function useBreakpoint(defaultValue?, breakpointValues?) {
-    const [[innerWidth, innerHeight], setInnerWidth] = useState(cachedIw)
+    const [[innerWidth, innerHeight], setInnerWidth] = useState([cachedIw, cachedIh])
     useResize(() => {
         cachedIw = getInnerWidth()
         cachedIh = getInnerHeight()
         setInnerWidth([cachedIw, cachedIh])
     })
-    return useMemo(() => calculateValue(defaultValue, breakpointValues, innerWidth, innerHeight), [innerWidth, defaultValue])
+    return useMemo(() => calculateValue(defaultValue, breakpointValues, innerWidth, innerHeight), [innerWidth, innerHeight, defaultValue])
 }
 
 export default useBreakpoint