-
Notifications
You must be signed in to change notification settings - Fork 0
[동현] State-Management #1
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: donghyun
Are you sure you want to change the base?
Conversation
Seoin02
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.
아티클을 토대로 이해하기 바빠서 의문을 가지거나 다른 자료를 찾을 생각을 못했는데, 동현님 PR과 코드리뷰 받고 반성합니다...! 코드 168줄인데도 이해하는데 시간이 걸리네요ㅜㅜ 고생많으셨어요
|
|
||
| const dispatch = (action: Action) => { | ||
| if (!isPlainObject(action)) { | ||
| throw new Error(`해당 ${action}은 순수 객체가 아니에요! 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.
에러 처리 굿입니다!
| } | ||
|
|
||
| if (typeof action.type !== 'string') { | ||
| throw new Error(`action type은 반드시 문자열이어야 합니다.`) |
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.
타입스크립트는 컴파일 시 타입 에러를 발생시키고, 런타임에서의 타입 안전성을 보장하지 않기 때문에 예외 처리 등을 해야 한다는 걸 덕분에 배웠습니다!!
| @@ -0,0 +1,5 @@ | |||
| const randomString = () => Math.random().toString(36).substring(7).split('').join('.') | |||
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.
이건 어떤 용도인가요?
| */ | ||
| const initialState = 0 | ||
|
|
||
| export const ACTION_TYPE = { |
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.
type이나 util은 파일을 분리했는데 왜 상수는 파일을 분리하지 않으신건가요??
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.
type, util 파일을 분리한 곳은 아마 redux를 만든 곳일거에요. 거기는 코드가 조금 많아서 분리하는게 좋다라는 생각이였고, 사용하는 reducer에서는 한 파일에 모두 다 넣었습니다! 사용하는 입장에서 규모가 크지않다면 한 파일로 작성하는게 좋겠다 라는 생각을 했어요!
| @@ -0,0 +1,5 @@ | |||
| const randomString = () => Math.random().toString(36).substring(7).split('').join('.') | |||
|
|
|||
| export const ActionTypes = { | |||
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의 초기 값을 지정하는 건가요??
고민한 것.
useSyncExternalStore라는 외부 스토어를 구독할 수 있는 Hook 덕분이라는것을 알게되었다.배운 점.