From 3c3b4472e21af58231daba5d59ab20d1a81961b7 Mon Sep 17 00:00:00 2001 From: Gerardo Marx Date: Mon, 1 Jun 2026 08:13:32 -0600 Subject: [PATCH] Passing data via Props --- src/App.tsx | 10 ++++++++-- src/components/ListGroup.tsx | 10 +++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 3ad0baa..e0ac47d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,13 @@ import ListGroup from "./components/ListGroup"; function App() { - return
; + let items = ["New York", "San Francisco", "Tokyo", "London"]; + + return ( +
+ +
+ ); } -export default App; \ No newline at end of file +export default App; diff --git a/src/components/ListGroup.tsx b/src/components/ListGroup.tsx index 19d1dcc..f815104 100644 --- a/src/components/ListGroup.tsx +++ b/src/components/ListGroup.tsx @@ -1,13 +1,17 @@ import { useState } from "react"; +// {items: [string], heading: string} +interface Props { + items: string []; + heading: string; +} -function ListGroup() { - let items = ["New York", "San Francisco", "Tokyo", "London"]; +function ListGroup({items, heading}: Props) { const [selectedIndex, setSelectedIndex] = useState(-1); return ( <> -

List Name

+

{heading}

{items.length === 0 &&

No items found

}