-
Notifications
You must be signed in to change notification settings - Fork 4
[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
base: chorom-ham
Are you sure you want to change the base?
Changes from 2 commits
b3a3b9c
8693d70
ce1b9f8
17c5fd0
9a94235
73e11f9
40d76a7
512309f
aa17100
163f3c8
6732b8c
d661874
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ import styled from 'styled-components'; | |
| import TodoInput from './TodoInput'; | ||
| import TodoCard from './TodoCard'; | ||
|
|
||
| const Div = styled.div` | ||
| const Wrapper = styled.div` | ||
| width: 80%; | ||
| background-color: rgb(222, 242, 167); | ||
| margin: 0px auto; | ||
|
|
@@ -21,7 +21,6 @@ class Todo extends Component { | |
| } | ||
|
|
||
| onClick = (index) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Todo 컴포넌트 안에 onClick 함수가 있으니 마치 Todo 컴포넌트를 클릭했을때 발동할 것 같다는 오해의 소지가 있네요~ |
||
| console.log(this.state.todoList) | ||
| let newTodoList = Array.from(this.state.todoList) | ||
| newTodoList.splice(index, 1); | ||
| this.setState({ todoList: newTodoList }); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이 부분도 spread operator와 slice를 이용해서 리팩토링 해보시겠어요?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 해보겠습니다! |
||
|
|
@@ -31,34 +30,25 @@ class Todo extends Component { | |
| if (this.state.todoList.length === 0) { | ||
| return "표시할 TODO가 없어요!"; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 오늘 배운 조건부 렌더링을 활용해 리팩토링 해보는건 어떨까요? 참고할만한 글의 논리 && 연산자가 있는 인라인 조건을 참고해주세요!
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 리팩토링해보겠습니다
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 리팩토링 시도해봤는데 리턴에 계속 밑줄이 그어지면서 오류라고 뜨네요ㅜㅜ
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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++) { | ||
| showTodoList.push( | ||
| <TodoCard | ||
| index={index} | ||
| todo={this.state.todoList[index]} | ||
| onClick={this.onClick} | ||
| />); | ||
| } | ||
| return showTodoList; | ||
| } | ||
|
|
||
| let showTodoList = this.state.todoList.map((_todo, index) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 넵 수정하겠습니다 |
||
| return <TodoCard index={index} todo={_todo} onClick={this.onClick}/>; | ||
| }); | ||
| return showTodoList; | ||
| } | ||
|
|
||
| onSubmit = (_todo) => { | ||
| let newTodoList = Array.from(this.state.todoList); | ||
| newTodoList.push(_todo); | ||
| this.setState({ | ||
| todoList: newTodoList | ||
| todoList: [...this.state.todoList,_todo] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| }); | ||
| } | ||
|
|
||
| render() { | ||
| return ( | ||
| <Div> | ||
| <Wrapper> | ||
| <TodoInput onSubmit={this.onSubmit}></TodoInput> | ||
| {this.getTodo()} | ||
| </Div> | ||
| </Wrapper> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,13 +11,16 @@ const Button = styled.input` | |
| font-size: 1.5rem; | ||
| border-radius: 0.5rem; | ||
| ` | ||
| const Form = styled.form`` | ||
| const Input = styled.input`` | ||
|
|
||
|
|
||
| // 힌트 : Row, Input, Button | ||
| class TodoInput extends Component { | ||
|
|
||
| render() { | ||
| return ( | ||
| <form name="addListForm" | ||
| <Form name="addListForm" | ||
| onSubmit={(e) => { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 함수를 분리해서 써볼까요~ |
||
| e.preventDefault(); | ||
| if (e.target.todo.value === "") | ||
|
|
@@ -30,7 +33,7 @@ class TodoInput extends Component { | |
| } | ||
| > | ||
| <Row> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Row를 없애고 Row의 스타일링을 Form에 넣어줘도될 것 같아요~ |
||
| <input | ||
| <Input | ||
| type="text" | ||
| name="todo" | ||
| placeholder="TODO를 입력하세요" /> | ||
|
|
@@ -39,7 +42,7 @@ class TodoInput extends Component { | |
| name="addButton" | ||
| value="ADD" /> | ||
| </Row> | ||
| </form> | ||
| </Form> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
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.
Component 작성시 중요한 정보 순서대로 위쪽에 배치하는게 좋습니다!
컴포넌트들의 스타일링들은 비교적 중요도가 떨어지겠죠?!
맨 아래에 위치시켜주시면 됩니다~