diff --git a/src/App.jsx b/src/App.jsx index aa4d827..bc8c345 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -10,61 +10,95 @@ const initialTodos = [ ]; export default function App() { + const [isName, setIsName] = useState() + const [isEditing, setIsEditing] = useState(false); const [todos, setTodos] = useState( initialTodos ); function handleAddTodo(title) { - todos.push({ - id: nextId++, - title: title, - done: false - }); + setTodos([ + + ...todos, + { + id: nextId++, + title: title, + done: false, + } + ]) } function handleChangeTodo(nextTodo) { - const todo = todos.find(t => - t.id === nextTodo.id + setTodos( + todos.map((t) => { + if (t.id === nextTodo.id) { + return nextTodo; + } else { + return t; + } + }), ); - todo.title = nextTodo.title; - todo.done = nextTodo.done; } function handleDeleteTodo(todoId) { - const index = todos.findIndex(t => - t.id === todoId - ); - todos.splice(index, 1); + setTodos(todos.filter((t) => t.id != todoId)); } + const [info, setInfo] = useState({ + name: "", + major: "", + email: "", + github: "", + }); + const onChange = (e) => { + setInfo({...info, [e.target.name]:e.target.value}); + }; + const [isEdit, setIsEdit] = useState(false); + const handleClickBtn = () => { + setIsEdit(!isEdit); + }; return ( <> + {isEdit ? ( +
+ ):( + <> +