-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
➖ Remove ReachUI window-size dependency #1378
- Loading branch information
1 parent
9a84fab
commit f26a592
Showing
3 changed files
with
38 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
web/pageComponents/shared/siteMenu/hooks/useWindowDimensions.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { useEffect, useState } from 'react' | ||
|
||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong. |
||
type WindowDimentions = { | ||
width: number | undefined | ||
height: number | undefined | ||
} | ||
|
||
const useWindowDimensions = (): WindowDimentions => { | ||
const [windowDimensions, setWindowDimensions] = useState<WindowDimentions>({ | ||
width: undefined, | ||
height: undefined, | ||
}) | ||
useEffect(() => { | ||
function handleResize(): void { | ||
setWindowDimensions({ | ||
width: window.innerWidth, | ||
height: window.innerHeight, | ||
}) | ||
} | ||
handleResize() | ||
window.addEventListener('resize', handleResize) | ||
return (): void => window.removeEventListener('resize', handleResize) | ||
}, []) | ||
|
||
return windowDimensions | ||
} | ||
|
||
export default useWindowDimensions |
this hook is a duplicate of web/lib/hooks/useWindowSize.ts