-
Notifications
You must be signed in to change notification settings - Fork 468
/
Copy pathtodoForm.js
29 lines (27 loc) · 1.05 KB
/
todoForm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React from 'react'
import "../../styles/todoForm.css"
import {TodoContext} from "../../Contexts/todoContext"
function TodoForm(){
const [newTodoValue, setNewTodoValue] = React.useState("")
const {setOpenModal,addTodo } = React.useContext(TodoContext)
const OnSubmit = e =>{
addTodo(newTodoValue)
e.preventDefault()
setOpenModal(false)
}
const OnCancel = () =>setOpenModal(false)
const OnChange = e=>{ setNewTodoValue(e.target.value)}
return(
<>
<form onSubmit={OnSubmit}>
<label>Escribe tu nuevo Todo</label>
<textarea placeholder='escribe aquí...' value={newTodoValue} onChange={OnChange}></textarea>
<div className='TodoForm-buttonContainer'>
<button className='TodoForm-button TodoForm-button--cancel' type='button' onClick={OnCancel}>cancelar</button>
<button className='TodoForm-button TodoForm-button--add' type='submit'>agregar</button>
</div>
</form>
</>
)
}
export {TodoForm}