Jonatan Gezelius 2 vuotta sitten
vanhempi
commit
00cbf70dc4

+ 13 - 1
react-again-tutorial/src/App.tsx

@@ -8,7 +8,19 @@ import { MouseEvent } from "react";
 function App() {
   const items = ["Dude", "Man", "Shit", "Is it working?"];
 
-  return <ListGroup items={items} heading="Man shit list" />;
+  const handleSelectItem = (item: string) => {
+    console.debug("Yoman!");
+  };
+
+  return (
+    <div>
+      <ListGroup
+        items={items}
+        heading="Man shit list"
+        onSelectedItem={handleSelectItem}
+      />
+    </div>
+  );
 }
 
 export default App;

+ 1 - 0
react-again-tutorial/src/components/ListGroup.tsx

@@ -3,6 +3,7 @@ import { useState } from "react";
 interface ListGroupProps {
   items: string[];
   heading: string;
+  onSelectedItem?: (item: string) => void;
 }
 
 function ListGroup({ items, heading }: ListGroupProps) {