File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 1+ import { useState } from "react" ;
12import "./App.css" ;
23import TodoTable from "./components/TodoTable" ;
34
45function App ( ) {
5- const todos = [
6+ const seededTodos = [
67 { rowNumber : 1 , rowDescription : "Feed puppy" , rowAssigned : "User One" } ,
78 { rowNumber : 2 , rowDescription : "Water plants" , rowAssigned : "User Two" } ,
89 { rowNumber : 3 , rowDescription : "Make dinner" , rowAssigned : "User One" } ,
910 ] ;
11+ const [ todos , setTodos ] = useState ( seededTodos ) ;
1012
1113 const addTodo = ( ) => {
1214 if ( todos . length > 0 ) {
@@ -15,8 +17,7 @@ function App() {
1517 rowDescription : "New todo" ,
1618 rowAssigned : "User Three" ,
1719 } ;
18- todos . push ( newTodo ) ;
19- return < TodoTable todos = { todos } />
20+ setTodos ( newTodo ) ;
2021 }
2122 } ;
2223
@@ -25,6 +26,7 @@ function App() {
2526 < div className = "card" >
2627 < div className = "card-header" > Your Todo's</ div >
2728 < div className = "card-body" >
29+ < TodoTable todos = { todos } />
2830 < button className = "btn btn-primary" onClick = { addTodo } >
2931 Add New To-Do
3032 </ button >
You can’t perform that action at this time.
0 commit comments