From 1af168ddb4b147ef3e45189a635ccc11b36543bd Mon Sep 17 00:00:00 2001 From: andrzej Date: Sun, 6 Oct 2024 17:33:43 +0200 Subject: [PATCH] window size hook --- src/App.tsx | 5 +++++ src/hooks/useWindowDimensions.ts | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 src/hooks/useWindowDimensions.ts diff --git a/src/App.tsx b/src/App.tsx index b68c756..a6df8e3 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -64,6 +64,9 @@ function App() { minHeight: "100%", aspectRatio: "16/9" } + function setMoviesHandler(movies: Movie[]) { + } + return ( <>
@@ -72,8 +75,10 @@ function App() {
+ { + function handleResize() { + setWindowDimensions(getWindowDimensions()); + } + + window.addEventListener('resize', handleResize); + return () => window.removeEventListener('resize', handleResize); + }, []); + + return windowDimensions; +}