Skip to content

Commit

Permalink
fix: missing dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Vincze committed May 15, 2020
1 parent a9733e4 commit cbf6f3a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ storiesOf('Hooks|useBreakpoint', module).add(
['large', 'is large']
])

console.log(useBreakpoint())

return <div>
Example code
<pre>{`const value = useBreakpoint('none', [
Expand Down
4 changes: 2 additions & 2 deletions src/useBreakpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cbf6f3a

Please sign in to comment.