Skip to content

Commit 411cc41

Browse files
committed
Add todos iterating over collection
1 parent 8154794 commit 411cc41

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

react-todos/src/App.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@ import "./App.css";
22
import TodoRowItem from "./components/TodoRowItem";
33

44
function App() {
5+
const todos = [
6+
{ rowNumber: 1, rowDescription: "Feed puppy", rowAssigned: "User One" },
7+
{ rowNumber: 2, rowDescription: "Water plants", rowAssigned: "User Two" },
8+
{ rowNumber: 3, rowDescription: "Make dinner", rowAssigned: "User One" },
9+
];
10+
511
return (
612
<div className="mt-5 container">
713
<div className="card">
@@ -16,8 +22,13 @@ function App() {
1622
</tr>
1723
</thead>
1824
<tbody>
19-
<TodoRowItem number={1} task={"Feed dog"} assignee={"Eric"} />
20-
<TodoRowItem number={2} task={"Get haircut"} assignee={"Eric"} />
25+
{todos.map((todo) => (
26+
<TodoRowItem
27+
rowNumber={todo.rowNumber}
28+
rowDescription={todo.rowDescription}
29+
rowAssigned={todo.rowAssigned}
30+
/>
31+
))}
2132
</tbody>
2233
</table>
2334
</div>
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
export default function TodoRowItem(props) {
2-
return (
1+
export default function TodoRowItem(props) {
2+
return (
33
<tr>
4-
<th scope='row'>{props.number}</th>
5-
<td>{props.task}</td>
6-
<td>{props.assignee}</td>
4+
<th scope="row">{props.rowNumber}</th>
5+
<td>{props.rowDescription}</td>
6+
<td>{props.rowAssigned}</td>
77
</tr>
8-
)
8+
);
99
}

0 commit comments

Comments
 (0)