Add useWindowWidth hook and HistoryCard component

This commit is contained in:
Mo Tarbin 2024-07-09 17:39:16 -04:00
parent c4bf06b11c
commit a24134f852
4 changed files with 157 additions and 105 deletions

View file

@ -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