Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design2
/
2015104215
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
jaehyuk-jang
2021-06-11 01:09:58 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3b982bb409b8a0238bdbd96479a86acdddcaf6a4
3b982bb4
1 parent
aac57ef9
useWindowSize() for checking web mobile
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
0 deletions
project/packages/web/src/hooks/index.ts
project/packages/web/src/hooks/useWindowSize.ts
project/packages/web/src/hooks/index.ts
0 → 100644
View file @
3b982bb
export
{
default
as
useWindowSize
}
from
'./useWindowSize'
;
project/packages/web/src/hooks/useWindowSize.ts
0 → 100644
View file @
3b982bb
import
{
useLayoutEffect
,
useState
}
from
'react'
;
export
default
function
useWindowSize
()
{
const
[
size
,
setSize
]
=
useState
([
0
,
0
]);
useLayoutEffect
(()
=>
{
function
updateSize
()
{
setSize
([
window
.
innerWidth
,
window
.
innerHeight
]);
}
window
.
addEventListener
(
'resize'
,
updateSize
);
updateSize
();
return
()
=>
window
.
removeEventListener
(
'resize'
,
updateSize
);
},
[]);
return
size
;
}
Please
register
or
login
to post a comment