Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! 이 PR은 React와 Vite를 사용하여 TODO 애플리케이션의 초기 개발 환경을 설정하고, 핵심 기능을 구현합니다. 여기에는 프로젝트의 기본 파일 구조, 의존성 관리, ESLint 설정, 그리고 TODO 항목을 추가, 삭제, 토글할 수 있는 기본적인 UI 컴포넌트 및 상태 관리 로직이 포함됩니다. Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request initializes a new React project using Vite, setting up ESLint and implementing a basic Todo application with React Context for state management. Key changes include adding standard project files like .gitignore, package.json, index.html, and src/App.css, along with core React components (App.jsx, ListForm.jsx, ToDoWriteForm.jsx) and a TodoContext.jsx for global state. Review comments highlight several critical issues and improvement opportunities: a merge conflict in README.md needs resolution; the ToggleE function in TodoContext.jsx directly mutates state and misuses filter, requiring a refactor to use map for immutability; there are numerous unnecessary imports and large blocks of commented-out code across App.jsx, ListForm.jsx, ToDoWriteForm.jsx, and TodoContext.jsx that should be removed for clarity; a redundant src/hooks/useContext.js file with a name conflicting with React's built-in hook should be deleted; lastid is imported but unused in ListForm.jsx; index is incorrectly used as a key in ListForm.jsx's map function, which should be replaced with todo.id; and the removeTodo function in TodoContext.jsx has a misleading parameter name (sindex instead of id) and unclear callback arguments (ab, cb).
| <<<<<<< HEAD | ||
| # React + Vite | ||
|
|
||
| This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. | ||
|
|
||
| Currently, two official plugins are available: | ||
|
|
||
| - [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh | ||
| - [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh | ||
|
|
||
| ## React Compiler | ||
|
|
||
| The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation). | ||
|
|
||
| ## Expanding the ESLint configuration | ||
|
|
||
| If you are developing a production application, we recommend using TypeScript with type-aware lint rules enabled. Check out the [TS template](https://github.com/vitejs/vite/tree/main/packages/create-vite/template-react-ts) for information on how to integrate TypeScript and [`typescript-eslint`](https://typescript-eslint.io) in your project. | ||
| ======= | ||
| # 리액트 투두 앱 만들기 미션 레포 | ||
| >>>>>>> 23993ab9d9dd5f873ce4a2795af61a2fdb1f6866 |
| const ToggleE = (ina) => { | ||
| //const filterToggle = todos.filter((ab, cd) => isBigEnough(ab.id, ina, ab)); | ||
| const filterToggle = todos.filter( | ||
| (ab, cd) => | ||
| (ab.id == ina | ||
| ? (ab.checked = !ab.checked) | ||
| : (ab.checked = ab.checked)) || true, | ||
| ); | ||
| setTodos(filterToggle); | ||
| }; |
There was a problem hiding this comment.
ToggleE 함수에서 React 상태를 직접 변경(mutate)하고 있으며, filter 메소드를 잘못 사용하고 있습니다.
- 상태 불변성 위반:
ab.checked = !ab.checked와 같이 상태 객체를 직접 수정하면 안 됩니다. React에서 상태는 불변(immutable)으로 다루어야 합니다. filter메소드 오용:filter는 특정 조건에 맞는 요소만 모아 새로운 배열을 만드는 함수입니다. 여기서는 배열 요소를 수정하는 용도로 사용되었고,|| true때문에 실제 필터링은 일어나지 않습니다. 상태 업데이트에는map을 사용하는 것이 올바른 방법입니다.
아래와 같이 map을 사용하여 새로운 배열을 생성하고, 상태를 업데이트하는 방식으로 수정하는 것을 권장합니다.
const ToggleE = (id) => {
setTodos(
todos.map((todo) =>
todo.id === id ? { ...todo, checked: !todo.checked } : todo,
),
);
};| @@ -0,0 +1,51 @@ | |||
| import "./App.css"; | |||
| import "./components/ToDoWriteForm.jsx"; | |||
| // const { todos, lastid, addtodo, removeTodo, ToggleE } = useContext(); | ||
| /* const [todoId, setTodoId] = useState(4); | ||
| const lastid = useRef(4); | ||
|
|
||
| const [todos, setTodos] = useState([ | ||
| { id: 3, text: "공부하기", checked: false }, | ||
| { id: 2, text: "저녁먹기", checked: false }, | ||
| { id: 1, text: "야구보기", checked: true }, | ||
| ]); | ||
| */ | ||
| /*function isBigEnough(cd, ina, ab) { | ||
| cd == ina ? (ab.checked = !ab.checked) : (ab.checked = ab.checked); | ||
| return true; | ||
| }*/ | ||
| /* const handleOnSubmit = (e) => { | ||
| e.preventDefault(); | ||
| const form = e.target; | ||
| return form.target.value; | ||
| };*/ | ||
| /* const addtodo = (text) => { | ||
| setTodos([{ id: lastid.current++, text, checked: false }, ...todos]); | ||
| }; | ||
| const removeTodo = (sindex) => { | ||
| const filterTodos = todos.filter((ab, cb) => ab.id != sindex); | ||
| setTodos(filterTodos); | ||
| }; | ||
| const ToggleE = (ina) => { | ||
| //const filterToggle = todos.filter((ab, cd) => isBigEnough(ab.id, ina, ab)); | ||
| const filterToggle = todos.filter( | ||
| (ab, cd) => | ||
| (ab.id == ina | ||
| ? (ab.checked = !ab.checked) | ||
| : (ab.checked = ab.checked)) || true, | ||
| ); | ||
| setTodos(filterToggle); | ||
| };*/ |
| /*function isBigEnough(cd, ina, ab) { | ||
| cd == ina ? (ab.checked = !ab.checked) : (ab.checked = ab.checked); | ||
| return true; | ||
| }*/ | ||
| /* const handleOnSubmit = (e) => { | ||
| e.preventDefault(); | ||
| const form = e.target; | ||
| return form.target.value; | ||
| };*/ |
| import { useTodos } from "../context/TodoContext.jsx"; | ||
|
|
||
| function ListForm() { | ||
| const { todos, lastid, removeTodo, ToggleE } = useTodos(); |
| <> | ||
| <ul> | ||
| {todos.map((todo, index) => ( | ||
| <li key={index}> |
| {todo.checked.toString()} | ||
| {todo.id} | ||
| {todo.text} |
| @@ -0,0 +1,22 @@ | |||
| import "../App.jsx"; | |||
| const removeTodo = (sindex) => { | ||
| const filterTodos = todos.filter((ab, cb) => ab.id != sindex); | ||
| setTodos(filterTodos); | ||
| }; |
There was a problem hiding this comment.
removeTodo 함수의 파라미터 이름이 sindex로 되어있지만, 실제로는 id와 비교하고 있습니다. 혼동을 피하기 위해 id로 변경하는 것이 좋습니다. 또한, filter의 콜백 함수 인자 ab, cb는 의미를 알기 어렵습니다. todo와 같이 명확한 이름으로 변경하면 가독성이 향상됩니다.
| const removeTodo = (sindex) => { | |
| const filterTodos = todos.filter((ab, cb) => ab.id != sindex); | |
| setTodos(filterTodos); | |
| }; | |
| const removeTodo = (id) => { | |
| const filterTodos = todos.filter((todo) => todo.id !== id); | |
| setTodos(filterTodos); | |
| }; |
| @@ -0,0 +1,38 @@ | |||
| import { useState, useRef } from "react"; | |||
|
기본적인 Todo 기능들이 잘 구현되어 있어서 React 상태 관리 흐름을 이해하는 데에 적절한 프로젝트라고 느꼈습니다 할 일 추가, 삭제, 완료 체크/해제까지 핵심 기능이 빠짐없이 동작하고 있고체크 상태에 따라 취소선을 적용한 부분도 사용자 입장에서 직관적으로 잘 표현된 것 같습니다. 다만 몇 가지 개선해보면 더 좋을 것 같다고 느낀 부분입니다 전체적으로 React의 기본 개념(useState, 이벤트 처리 등)을 잘 활용한 깔끔한 구현이라고 생각합니다. |
이 과제는 React를사용해 간단한 Todo List를 구현하는 프로젝트입니다.
컴포넌트 구조와 상태 관리를 이해하고,
할 일을 입력하면 목록에 추가되고, 삭제할 수 있으며, 체크버튼으로 true false 확인
기능 요약
할 일 추가
할 일을 입력하고 'Add' 버튼으로 새 할 일 생성
할 일 삭제
할 일 항목의 'Delete' 버튼으로 목록에서 삭제
완료 체크/해제
체크박스 클릭으로 할 일 완료/미완료 상태 전환
(완료 시 텍스트에 취소선 표시)
스크린샷
