aboutsummaryrefslogtreecommitdiffstats
path: root/src/hooks
diff options
context:
space:
mode:
authorLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-09 21:21:16 -0400
committerLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-09 21:21:16 -0400
commitc684bdb9ece99935c4c5f3a3eb81787cc2a0ef19 (patch)
treedb6b73e9722ed92b2471cd86dcb32be82322d85a /src/hooks
parent1255ea83568701f460f721e0c1a5d461fb0c5a25 (diff)
parente25a6d3be9b9ae443dd3e1cd57a8c5912cc088b2 (diff)
downloaddonetick-frontend-c684bdb9ece99935c4c5f3a3eb81787cc2a0ef19.tar.gz
donetick-frontend-c684bdb9ece99935c4c5f3a3eb81787cc2a0ef19.tar.bz2
donetick-frontend-c684bdb9ece99935c4c5f3a3eb81787cc2a0ef19.zip
Merge branch 'dev'
Diffstat (limited to 'src/hooks')
-rw-r--r--src/hooks/useWindowWidth.js14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/hooks/useWindowWidth.js b/src/hooks/useWindowWidth.js
new file mode 100644
index 0000000..fa79cc4
--- /dev/null
+++ b/src/hooks/useWindowWidth.js
@@ -0,0 +1,14 @@
+import { useEffect, useState } from 'react'
+function useWindowWidth() {
+ const [width, setWidth] = useState(window.innerWidth)
+
+ useEffect(() => {
+ const handleResize = () => setWidth(window.innerWidth)
+ window.addEventListener('resize', handleResize)
+ return () => window.removeEventListener('resize', handleResize)
+ }, [])
+
+ return width
+}
+
+export default useWindowWidth