Skip to content

[2주차] 함초롬 미션 제출합니다. #3

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

Open
wants to merge 12 commits into
base: chorom-ham
Choose a base branch
from

Conversation

chorom-ham
Copy link
Member

계속 오류가 나서 힘들었던 미션이었습니다 😢
arrow function 문법을 몰라 바인딩에 문제가 있었습니다. arrow function 문법을 다시 한 번 확인하겠습니다.
빈 배열 선언할 때 '=[]'로 하지 않아서 오류가 났는데 앞으로는 이런 실수했던 경험 잘 기억하고 같은 실수 없도록 하겠습니다!

감사합니다. 🙇‍♀

@greatSumini greatSumini changed the base branch from master to chorom-ham October 6, 2019 11:33
Copy link
Member

@greatSumini greatSumini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ㅋㅋㅋ 오늘의 삽질은 최신문법의 소중함을 깨닫는 좋은 기회라고 생각해주셨으면 좋겠습니다.
고생하셨습니다! 리뷰 반영 후 커밋해주세요~

@@ -1,32 +1 @@
# react-todo
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

README.md도 작성해주세요 😂

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 넵!

import styled from 'styled-components';

import TodoInput from './TodoInput';
import TodoCard from './TodoCard';

const Div = styled.div`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 Component의 의도와 역할을 더 잘 설명할 수 잇는 네이밍이 좋을 것 같아요.
ex) Wrapper, Container, ...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

네이밍 조언 감사합니다:)

if (this.state.todoList.length === 0) {
return "표시할 TODO가 없어요!";
}
else {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

위의 if문에서 true로 걸렸다면 이미 return 됐을테니까, 여기서 else라고 써줄 필요가 없습니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 그렇네요..!


getTodo = () => {
if (this.state.todoList.length === 0) {
return "표시할 TODO가 없어요!";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오늘 배운 조건부 렌더링을 활용해 리팩토링 해보는건 어떨까요? 참고할만한 글의 논리 && 연산자가 있는 인라인 조건을 참고해주세요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 리팩토링해보겠습니다

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리팩토링 시도해봤는데 리턴에 계속 밑줄이 그어지면서 오류라고 뜨네요ㅜㅜ

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

앗 완전히 구조를 바꿔야해요! ㅎㅎ.. 작성스타일 차이로 볼 수도 있는 부분이라고 생각해서 꼭 고치진 않으셔도 됩니당

}
else {
let showTodoList = [];
for (let index = 0; index < this.state.todoList.length; index++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map함수를 사용해 리팩토링 해봐도 좋을 것 같아욯ㅎ

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

map함수 syntax를 익혀보도록 하겠습니다! 아직 안 익숙하다보니 계속 익숙한 방식만 쓰게되네요 😅

let newTodoList = Array.from(this.state.todoList);
newTodoList.push(_todo);
this.setState({
todoList: newTodoList
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
todoList: newTodoList
todoList: [...this.state.todoList, _todo]

spread operator를 이용해 깔끔하게 리팩토링할 수 있습니다~

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

훨씬 깔끔한 느낌이네요! 감사합니다

import styled from 'styled-components';

const Div = styled.div`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이것 역시 더 좋은 네이밍을 찾을 수 있을 것 같아요! div는 아무것도 나타내지 못하거든요 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 네이밍 더 신경쓰도록 하겠습니다.

render() {
return <div>화이팅^^</div>;
return (
<form name="addListForm"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

기본 제공되는 tag를 사용하지 않도록 리팩토링 해보세요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 기본 제공 태그를 지양하도록 하겠습니다

@@ -12,8 +20,46 @@ class Todo extends Component {
};
}

onClick = (index) => {
console.log(this.state.todoList)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

제가 추가한 코드네요 😂
이런 테스팅용 코드는 PR시에 모두 제거해주셔야합니다!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

다 지웠다고 생각했는데 남아있었군요..! 확인했습니다

Copy link
Member

@greatSumini greatSumini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다! 추가 리뷰 해드렸으니 참고해주세요~

return showTodoList;
}

let showTodoList = this.state.todoList.map((_todo, index) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. 추가적인 수정사항이 없으므로 let보다는 const가 적합해보이네요
  2. map함수의 결과를 그대로 return 해주셔도 됩니당

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 수정하겠습니다

this.setState({
todoList: newTodoList
todoList: [...this.state.todoList,_todo]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -21,7 +21,6 @@ class Todo extends Component {
}

onClick = (index) => {
console.log(this.state.todoList)
let newTodoList = Array.from(this.state.todoList)
newTodoList.splice(index, 1);
this.setState({ todoList: newTodoList });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분도 spread operator와 slice를 이용해서 리팩토링 해보시겠어요?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 해보겠습니다!

@chorom-ham
Copy link
Member Author

수정 완료했습니다~!

Copy link
Member

@greatSumini greatSumini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다 ㅎㅎ 점점 코드 질이 좋아지는게 눈에 보여서 제가 다 뿌듯하네요 👍
리뷰 반영 후 커밋부탁드립니다~

return <div>화이팅^^</div>;
return (
<Form name="addListForm"
onSubmit={(e) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

함수를 분리해서 써볼까요~

}
}
>
<Row>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Row를 없애고 Row의 스타일링을 Form에 넣어줘도될 것 같아요~

import styled from 'styled-components';

import TodoInput from './TodoInput';
import TodoCard from './TodoCard';

const Wrapper = styled.div`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Component 작성시 중요한 정보 순서대로 위쪽에 배치하는게 좋습니다!
컴포넌트들의 스타일링들은 비교적 중요도가 떨어지겠죠?!
맨 아래에 위치시켜주시면 됩니다~

@@ -12,8 +20,33 @@ class Todo extends Component {
};
}

onClick = (index) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo 컴포넌트 안에 onClick 함수가 있으니 마치 Todo 컴포넌트를 클릭했을때 발동할 것 같다는 오해의 소지가 있네요~
다른 네이밍으로 바꾸는게 좋을 것 같아요!

@@ -12,8 +20,33 @@ class Todo extends Component {
};
}

onClick = (index) => {
this.setState({ todoList: [...this.state.todoList.slice(0,index),...this.state.todoList.slice(index+1)] });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

와우 너무 잘 해주셨어요!!

@chorom-ham
Copy link
Member Author

피드백 반영해서 수정했습니다. 피드백 덕분에 더 좋은 코드에 대한 감도 생기고 더 나은 코드를 짤 수 있는 것 같습니다! 감사합니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants