Skip to content

Commit 4bd38ea

Browse files
committed
Create todo table component
1 parent 411cc41 commit 4bd38ea

File tree

2 files changed

+26
-19
lines changed

2 files changed

+26
-19
lines changed

react-todos/src/App.js

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import "./App.css";
2-
import TodoRowItem from "./components/TodoRowItem";
2+
import TodoTable from "./components/TodoTable";
33

44
function App() {
55
const todos = [
@@ -13,24 +13,7 @@ function App() {
1313
<div className="card">
1414
<div className="card-header">Your Todo's</div>
1515
<div className="card-body">
16-
<table className="table table-hover">
17-
<thead>
18-
<tr>
19-
<th scope="col">#</th>
20-
<th scope="col">Description</th>
21-
<th scope="col">Assigned</th>
22-
</tr>
23-
</thead>
24-
<tbody>
25-
{todos.map((todo) => (
26-
<TodoRowItem
27-
rowNumber={todo.rowNumber}
28-
rowDescription={todo.rowDescription}
29-
rowAssigned={todo.rowAssigned}
30-
/>
31-
))}
32-
</tbody>
33-
</table>
16+
<TodoTable todos = {todos} />
3417
</div>
3518
</div>
3619
</div>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import TodoRowItem from "./TodoRowItem";
2+
3+
export default function TodoTable(props) {
4+
return (
5+
<table className="table table-hover">
6+
<thead>
7+
<tr>
8+
<th scope="col">#</th>
9+
<th scope="col">Description</th>
10+
<th scope="col">Assigned</th>
11+
</tr>
12+
</thead>
13+
<tbody>
14+
{props.todos.map((todo) => (
15+
<TodoRowItem
16+
rowNumber={todo.rowNumber}
17+
rowDescription={todo.rowDescription}
18+
rowAssigned={todo.rowAssigned}
19+
/>
20+
))}
21+
</tbody>
22+
</table>
23+
);
24+
}

0 commit comments

Comments
 (0)