File tree Expand file tree Collapse file tree 2 files changed +39
-4
lines changed Expand file tree Collapse file tree 2 files changed +39
-4
lines changed Original file line number Diff line number Diff line change 11import { useState } from "react" ;
22import "./App.css" ;
3+ import NewTodoForm from "./components/NewTodoForm" ;
34import TodoTable from "./components/TodoTable" ;
45
56function App ( ) {
@@ -17,7 +18,7 @@ function App() {
1718 rowDescription : "New todo" ,
1819 rowAssigned : "User Three" ,
1920 } ;
20- setTodos ( todos => [ ...todos , newTodo ] )
21+ setTodos ( ( todos ) => [ ...todos , newTodo ] ) ;
2122 }
2223 } ;
2324
@@ -27,9 +28,7 @@ function App() {
2728 < div className = "card-header" > Your Todo's</ div >
2829 < div className = "card-body" >
2930 < TodoTable todos = { todos } />
30- < button className = "btn btn-primary" onClick = { addTodo } >
31- Add New To-Do
32- </ button >
31+ < NewTodoForm />
3332 </ div >
3433 </ div >
3534 </ div >
Original file line number Diff line number Diff line change 1+ import { useState } from "react" ;
2+
3+ export default function NewTodoForm ( ) {
4+ const [ description , setDescription ] = useState ( "" ) ;
5+ const [ assigned , setAssigned ] = useState ( "" ) ;
6+
7+ return (
8+ < div className = "mt-5" >
9+ < form >
10+ < div className = "mb-3" >
11+ < label className = "form-label" > Assigned</ label >
12+ < input
13+ type = "text"
14+ className = "form-control"
15+ required
16+ onChange = { ( e ) => setAssigned ( e . target . value ) }
17+ value = { assigned }
18+ > </ input >
19+ </ div >
20+ < div className = "mb-3" >
21+ < label className = "form-label" > Description</ label >
22+ < textarea
23+ className = "form-control"
24+ row = { 3 }
25+ required
26+ onChange = { ( e ) => setDescription ( e . target . value ) }
27+ value = { description }
28+ />
29+ </ div >
30+ < button type = "button" className = "btn btn-primary mt-3" >
31+ Add ToDo
32+ </ button >
33+ </ form >
34+ </ div >
35+ ) ;
36+ }
You can’t perform that action at this time.
0 commit comments