Skip to content
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

3주차 공부내용 정리 #5

Open
7 tasks
xianeml opened this issue Dec 26, 2021 · 1 comment
Open
7 tasks

3주차 공부내용 정리 #5

xianeml opened this issue Dec 26, 2021 · 1 comment
Labels
documentation 스터디에서 알게 된 내용 정리

Comments

@xianeml
Copy link
Owner

xianeml commented Dec 26, 2021

  • 타입단언과 타입 선언
  • 리덕스 saga, thunk 알게된 내용 정리
  • 제너레이터
  • 커링
  • 자바스크립트 실행 컨텍스트
  • 고차함수
  • Why Is Export Default Const invalid?
@xianeml xianeml added the documentation 스터디에서 알게 된 내용 정리 label Dec 26, 2021
@xianeml
Copy link
Owner Author

xianeml commented Dec 26, 2021

상태관리에서 불변성을 지키는 이유

객체, 배열 타입 변수는 참조할 때 메모리 주소를 따라가서 할당된 값을 그대로 사용하기 때문에 값이 의도치 않게 변경될 위험이 있다.
중앙 집중식으로 한곳에서 관리되는 상태를 여러 컴포넌트에서 참조하고 가공할 경우 상태가 이상하게 변경되어도 원인을 추적하기 어려워진다.
그래서 상태를 변경할 경우 원본 객체를 직접 변경하지 않고, 원본을 복사해서 새로운 변수에 할당 후 사용하는 것이 객체의 불변성을 지킬 수 있는 방법이다.
리액트, 리덕스 라이브러리에서 불변성을 강조하는 이유도 이 참조 문제 때문이다.
이전 상태와 새로 바뀐 상태값을 비교해서 바뀐 게 있으면 업데이트 하도록 동작하는데
상태값 새로 변경하다가 원본값까지 변경돼서 이전 상태와 새로운상태가 같아지면 아무런 동작도 일어나지 않기 때문에
상태 변경 시 항상 원본값을 새로운 메모리 주소에 할당해서 리액트가 변경사항을 명확하게 캐치할 수 있도록 하는것이 좋다!

참고

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation 스터디에서 알게 된 내용 정리
Projects
None yet
Development

No branches or pull requests

1 participant