jjin2e / react-todolist

0 stars 0 forks source link

주특기 숙련주차 과제 피드백 - 작성자: 류제천 튜터 #1

Open rjc1704 opened 1 year ago

rjc1704 commented 1 year ago

Overview

코드 레벨 피드백은 아래에 드리겠습니다.

rjc1704 commented 1 year ago

https://github.com/jjin2e/react-todolist/blob/5eeeb88757eccedf53e561f6ed11595d6e146c86/src/App.jsx#L37-L42 title과 contents를 참조하겠다고 했는데, title, contents가 정의된 코드가 없습니다.

title과 contents는 input 태그에서 사용되는 상태로 굳이 전역상태로 관리할 필요가 없어서 리덕스 없이 useState로 const [tittle, setTitle] = useState("");를 그대로 사용하셔도 무방합니다.

rjc1704 commented 1 year ago

https://github.com/jjin2e/react-todolist/blob/5eeeb88757eccedf53e561f6ed11595d6e146c86/src/redux/config/configStore.js#L2-L3 redux는 동일한 출처의 라이브러리이기 때문에 두줄로 나눠서 쓸 필요가 없고, import { createStore, combineReducers } from "redux"; 이렇게 한줄로 쓰시는 것을 더 권장 드립니다.

rjc1704 commented 1 year ago

https://github.com/jjin2e/react-todolist/blob/5eeeb88757eccedf53e561f6ed11595d6e146c86/src/App.jsx#L63-L64 redux를 쓰셨다면 ui를 그리는 state인 todos와 state를 변경하는 setTodos를 props로 넘겨줄 필요가 없습니다. 직접 TodoList 컴포넌트 내에서 useSelector로 todos를 구독하고, App.jsx 내에서 todo 추가 시, TodoList 컴포넌트에서 상태변화를 감지하고 리렌더링됩니다.