Skip to content

Conversation

@ksh0323a
Copy link

@ksh0323a ksh0323a commented Jan 5, 2020

  • redux 적용과제 - delete 버튼 추가.
    .. /note-hw 에 구현하였습니다.

 - redux 적용과제 - delete 버튼 추가.
function todoApp(state = initState, action) {
switch (action.type) {
case ADD_TODO:
let newNo = (state.todos.length === 0) ? 1 : state.todos[state.todos.length - 1].no + 1

Choose a reason for hiding this comment

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

직접 유니크한 값을 생성해 주는건 너무 좋은 판단이셨습니다!
다만 리듀서는 값을 생성해주는 곳이 아니라 전달 받은 데이터로 새로운 state를 만들어 주는곳입니다.
그래서 no값은 addTodo액션을 실행하는 컴포넌트에서 생성해서 액션으로 함께 넘겨주시는 것이 좋습니다.

}

handleSubmit = e => {
const text = this.state.text

Choose a reason for hiding this comment

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

객체구조 분해 할당을 이용해서 좀더 깔끔하게 원하는 값을 가져 오실수 있습니다!

https://developer.mozilla.org/ko/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#%EA%B0%9D%EC%B2%B4_%EA%B5%AC%EC%A1%B0_%EB%B6%84%ED%95%B4

ex) const { text } = this.state

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