-
Notifications
You must be signed in to change notification settings - Fork 122
To-do 리스트 Redux를 사용하여 리팩터링 하기 #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
deleteTask, addTask, updateTaskTitle 함수 만들어서 App컴포넌트와 분리시키기
useSelector으로 원하는 데이터 사용 dispatch로 action 전달사용 관심사 분리로 빼놓은 함수들을 action로 사용
액션에 맞춰서 데이터 수정
관리할 데이터인 store는 props로 전달
jest.mock('react-redux')로
react-router 모듈을 mock으로 만들었다.
그래서 하위 함수들을 모두 mock으로 만들었다.
13번줄
userSelector.mockImplemention()
로 selector함수 받아서 tasks 데이터 받고 가짜 useSelector을 실행시킨다.
moonkii
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/App.jsx
Outdated
| const initialState = { | ||
| newId: 100, | ||
| taskTitle: '', | ||
| tasks: [], | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이 부분은 왜 필요한가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactoring 하면서 삭제했습니다~😀
src/App.jsx
Outdated
| function updateTaskTitle(taskTitle) { | ||
| return { | ||
| type: 'updateTaskTitle', | ||
| payload: { | ||
| taskTitle, | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| function addTask() { | ||
| return { | ||
| type: 'addTask', | ||
|
|
||
| }; | ||
| } | ||
|
|
||
| function deleteTask(id) { | ||
| return { | ||
| type: 'deleteTask', | ||
| payload: { | ||
| id, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이제 따로 분리해주면 좋을 것 같네요 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
action으로 분리 했습니다!
src/store.js
Outdated
| tasks: [], | ||
| }; | ||
|
|
||
| function reducer(state = initialState, action) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reducer 도 이제 분리해주면 좋을 것 같아요 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reducer로 분리 했습니다!
InputContainer, ListContainer 로 관심사 분리
InputConatainer, ListContainer로 렌더한다.
다음 함수들을 구현 reduceUpdateTaskTitle reduceAddTask reduceDeleteTask
리뷰이번 Redux강의를 한번 제대로 실습 해보니 ReduxRedux를 구현하고자 reducer와 store, actions로 분류하는 과정이 Redux를 이해하는데 큰 도움이 되었습니다. 관심사 분리Container의 필요성이 공감되었습니다. 테스트 코드테스트 코드 작성이 구현하는 것만큼 시간이 걸렸습니다. 감사합니다!! |
moonkii
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리덕스도 잘 적용하셨고 테스트 코드도 깔끔하게 잘 작성하신 것 같아요!
주간회고 작성후 공유해주시면 merge 하도록하겠습니다

리뷰
Redux를 전에 여러번 시도했지만 이번 기회에 제대로 이해가 되었습니다. 감사합니다.
최근에 Recoil이 나왔는데 Redux를 배우는 동기부여가 조금 떨어졌었습니다.
아직은 리덕스가 더 많이 쓰이고 있어서 끝까지 참고 공부해보았습니다.
과제를 진행하다보니 내부 기능들을 까먹게 되는 것같습니다.
복습의 필요성이 더 커지는 과제였습니다.
mockImplementation처럼 jest문법들을 계속 접하게되어 jest를 계속 공부하는 좋은 계기였습니다.
감사합니다!
목표