From 84be14300ef292bef4273adc40968bdc6c0f8247 Mon Sep 17 00:00:00 2001 From: Hristo Nedelkov Date: Fri, 3 Nov 2023 11:07:46 +0200 Subject: [PATCH] Move window size useEffect --- src/pages/Dashboard/DashboardContent.tsx | 58 ++++-------------------- 1 file changed, 10 insertions(+), 48 deletions(-) diff --git a/src/pages/Dashboard/DashboardContent.tsx b/src/pages/Dashboard/DashboardContent.tsx index 5e8815e8..11961681 100644 --- a/src/pages/Dashboard/DashboardContent.tsx +++ b/src/pages/Dashboard/DashboardContent.tsx @@ -14,21 +14,11 @@ import NetworkCard from './NetworkCard/NetworkCard' import SyncStatusCard from './SyncStatusCards/SyncStatusCards' import MemoryCard from './MemoryCard/MemoryCard' import { XStack } from 'tamagui' +type DashboardContentProps = { + windowWidth: number; -const DashboardContent = () => { - const [windowWidth, setWindowWidth] = useState(window.innerWidth) - - useEffect(() => { - const handleResize = () => { - setWindowWidth(window.innerWidth) - } - - window.addEventListener('resize', handleResize) - return () => { - window.removeEventListener('resize', handleResize) - } - }, []) - +}; +const DashboardContent = ({ windowWidth }: DashboardContentProps) => { return ( { - {windowWidth < 1375 ? ( - windowWidth < 850 ? ( - DashboardContentLayoutPhone() - ) : ( - DashboardContentLayout() - ) + {windowWidth < 1400 ? ( + + DashboardContentLayout(windowWidth) + ) : ( { ) } -const DashboardContentLayout = () => { +const DashboardContentLayout = (windowWidth: number) => { return ( @@ -131,7 +119,7 @@ const DashboardContentLayout = () => { @@ -146,32 +134,6 @@ const DashboardContentLayout = () => { ) } -const DashboardContentLayoutPhone = () => { - return ( - - - - - - - - - - - - - ) -} export default DashboardContent