From 6915a00d32d9ce298b644612ebd2fca5b8cfc389 Mon Sep 17 00:00:00 2001 From: ebin5780 Date: Mon, 6 Jul 2026 17:08:36 +0900 Subject: [PATCH] =?UTF-8?q?1=EC=A3=BC=EC=B0=A8=20=EA=B3=BC=EC=A0=9C=20-=20?= =?UTF-8?q?todoList?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 28 +++++++++++++++++++++++++++- projects/1-react/src/App.jsx | 24 ++++++++++++++++-------- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index b512c09..bea28c1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,27 @@ -node_modules \ No newline at end of file +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? + +# vite +.vite \ No newline at end of file diff --git a/projects/1-react/src/App.jsx b/projects/1-react/src/App.jsx index 15ce937..ebc07cb 100644 --- a/projects/1-react/src/App.jsx +++ b/projects/1-react/src/App.jsx @@ -1,32 +1,40 @@ import { useState } from 'react'; import './index.css'; - -// 여기에 코드를 작성하세요 +import Placeholder from './components/placeholder'; // Placeholder 컴포넌트 임포트 (경로 확인 필요) +import Item from './components/item'; // Item 컴포넌트 임포트 (경로 확인 필요) +import Input from './components/input'; function App() { const [todos, setTodos] = useState([]); function addTodo(text) { - // 여기에 코드를 작성하세요 + if (!text.trim()) return; // 빈 값 입력 방지 + const newTodo = { + id : Date.now(), // 고유 ID 생성 + text : text, + completed : false, + }; + setTodos([...todos, newTodo]) // 스프레드 연산자로 새 배열 생성 } function toggleTodo(id) { - // 여기에 코드를 작성하세요 + setTodos(todos.map(todo => todo.id === id ? {...todo, completed : !todo.completed} : todo)); } function deleteTodo(id) { - // 여기에 코드를 작성하세요 + setTodos(todos.filter(todo => todo.id !== id)); } return (
- {/* 여기에 코드를 작성하세요 */} + {todos.length === 0 ? () : (todos.map(todo => ())) + }
- {/* 여기에 코드를 작성하세요 */} +
); } -export default App; +export default App; \ No newline at end of file