From 407cd8ea3a30a6295709e4211e706acb9fdacda0 Mon Sep 17 00:00:00 2001 From: David Katz <15Dkatz@shcp.edu> Date: Tue, 25 Oct 2022 15:02:05 -0700 Subject: [PATCH] Effects with Cleanup --- react-hooks/home/src/App.js | 14 +++++++++++++- react-hooks/home/src/Gallery.js | 6 +++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/react-hooks/home/src/App.js b/react-hooks/home/src/App.js index 9ecb754..2d26e54 100644 --- a/react-hooks/home/src/App.js +++ b/react-hooks/home/src/App.js @@ -6,6 +6,7 @@ import Gallery from './Gallery'; function App() { const [userQuery, setUserQuery] = useState(''); + const [showGallery, setShowGallery] = useState(true); const updateUserQuery = event => { console.log('userQuery', userQuery); @@ -23,6 +24,10 @@ function App() { window.open(`https://google.com/search?q=${userQuery}`, '_blank'); } + const toggleShowGallery = () => { + setShowGallery(!showGallery); + } + return (