aboutsummaryrefslogtreecommitdiffstats
path: root/src/hooks
diff options
context:
space:
mode:
authorLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-09 17:39:16 -0400
committerLibravatar Mo Tarbin <mhed.t91@gmail.com>2024-07-09 17:39:16 -0400
commita24134f8525373f5707b6c48aa77d3f4aff70799 (patch)
treea2a34c9ea849388dc39036aed3a99b79d9f055a4 /src/hooks
parentc4bf06b11cb5e8ebb1e7ed2ecc7bfeded0cfc42f (diff)
downloaddonetick-frontend-a24134f8525373f5707b6c48aa77d3f4aff70799.tar.gz
donetick-frontend-a24134f8525373f5707b6c48aa77d3f4aff70799.tar.bz2
donetick-frontend-a24134f8525373f5707b6c48aa77d3f4aff70799.zip
Add useWindowWidth hook and HistoryCard component
Diffstat (limited to 'src/hooks')
-rw-r--r--src/hooks/useWindowWidth.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/hooks/useWindowWidth.js b/src/hooks/useWindowWidth.js
new file mode 100644
index 0000000..92bf184
--- /dev/null
+++ b/src/hooks/useWindowWidth.js
@@ -0,0 +1,19 @@
+import { useEffect, useState } from 'react'
+const useWindowWidth = () => {
+ const [windowWidth, setWindowWidth] = useState()
+
+ useEffect(() => {
+ const handleResize = () => {
+ setWindowWidth(window.innerWidth)
+ }
+
+ window.addEventListener('resize', handleResize)
+
+ // Cleanup function to remove the event listener
+ return () => window.removeEventListener('resize', handleResize)
+ }, [])
+
+ return windowWidth
+}
+
+export default useWindowWidth