mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
19 lines
435 B
TypeScript
19 lines
435 B
TypeScript
import { useState, useEffect } from 'react';
|
|
|
|
const useWindowWidth = () => {
|
|
const [windowWidth, setWindowWidth] = useState(window.innerWidth);
|
|
|
|
useEffect(() => {
|
|
function handleResize() {
|
|
setWindowWidth(window.innerWidth);
|
|
}
|
|
|
|
window.addEventListener('resize', handleResize);
|
|
return () => window.removeEventListener('resize', handleResize);
|
|
}, []);
|
|
|
|
return windowWidth;
|
|
};
|
|
|
|
export default useWindowWidth;
|