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
{`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