From dda4d3d7ac30bc1ac4ea801e69ad902b8b550659 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Wed, 18 Oct 2023 18:09:54 +0300 Subject: [PATCH] Add event for window,innerWidth --- src/pages/Dashboard/DashboardContent.tsx | 112 +++++++++++++---------- 1 file changed, 63 insertions(+), 49 deletions(-) diff --git a/src/pages/Dashboard/DashboardContent.tsx b/src/pages/Dashboard/DashboardContent.tsx index 5895d1a2..4977edfd 100644 --- a/src/pages/Dashboard/DashboardContent.tsx +++ b/src/pages/Dashboard/DashboardContent.tsx @@ -12,61 +12,75 @@ import StorageCard from './StorageCard/StorageCard' import NetworkCard from './NetworkCard/NetworkCard' import SyncStatusCard from './SyncStatusCards/SyncStatusCards' import MemoryCard from './MemoryCard/MemoryCard' -const DashboardContent = () => ( - - +import { useEffect, useState } from 'react' +const DashboardContent = () => { + const [windowWidth, setWindowWidth] = useState(window.innerWidth); + + useEffect(() => { + const handleResize = () => { + setWindowWidth(window.innerWidth); + }; + + window.addEventListener('resize', handleResize); + return () => { + window.removeEventListener('resize', handleResize); + }; + }, []); + return ( + + + +
-
- - - -
- + +
- - - - - - - - + - - - - - - - - - - - -
-) + + + + + + + + + + + + + + + + + + + + +
+ ) +} export default DashboardContent