From e89591cdebf997381dd7e42f133583288b370922 Mon Sep 17 00:00:00 2001 From: Tree Jamie Date: Mon, 7 Apr 2025 21:21:36 +0100 Subject: [PATCH] a quick introduction to state --- react-foundations/index.html | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/react-foundations/index.html b/react-foundations/index.html index 56e0ba6..9a03cf8 100644 --- a/react-foundations/index.html +++ b/react-foundations/index.html @@ -13,9 +13,20 @@ return (

{title? title : 'Default Title'}

); } + + + + function HomePage() { const names = ['Ada Lovelace', 'Grace Hopper', 'Margaret Hamilton']; + const [likes, setLikes] = React.useState(0); + + function handleClick(){ + console.log("increment like count") + setLikes(likes + 1); + } + return (
@@ -24,6 +35,7 @@
  • {name}
  • ))} +
    ); }