From 8a15a26ff61cc18a14fa3687b388b464bbafb42d Mon Sep 17 00:00:00 2001 From: Laktionov Anton Date: Tue, 2 Jun 2026 20:43:00 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB=D0=B8=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=81=D1=82=D0=BE=D0=BC=D0=BD=D1=8B=D0=B9=20=D1=85?= =?UTF-8?q?=D1=83=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.jsx | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 6bf3ac6..974f9d7 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,10 +1,23 @@ -// удаляем все, оставляя лишь пустую функцию App ниже +import React, {useState, useEffect} from 'react' + +function useWindowWidth() { + const [width,setWidth] = useState(window.innerWidth) + + useEffect(() => { + const handleResize = () => setWidth(window.innerWidth); + window.addEventListener('resize',handleResize); + return () => window.removeEventListener('resize',handleResize); + },[]) + + return width +} function App() { + const width = useWindowWidth(); return ( <> {/* Добавьте тестовый контент для проверки */} -

Hello, React!

+

Hello, React!{width}

) }