perf: improve responsiveness

This commit is contained in:
plebeius.eth
2024-04-10 13:16:07 +02:00
parent b1fb9f9d0c
commit 62b83bf7ea
7 changed files with 36 additions and 12 deletions
+18
View File
@@ -0,0 +1,18 @@
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;