Open
Conversation
Seoin02
reviewed
Dec 16, 2024
Seoin02
left a comment
There was a problem hiding this comment.
아티클을 토대로 이해하기 바빠서 의문을 가지거나 다른 자료를 찾을 생각을 못했는데, 동현님 PR과 코드리뷰 받고 반성합니다...! 코드 168줄인데도 이해하는데 시간이 걸리네요ㅜㅜ 고생많으셨어요
|
|
||
| const dispatch = (action: Action) => { | ||
| if (!isPlainObject(action)) { | ||
| throw new Error(`해당 ${action}은 순수 객체가 아니에요! action은 항상 순수 객체여야 합니다.`) |
| } | ||
|
|
||
| if (typeof action.type !== 'string') { | ||
| throw new Error(`action type은 반드시 문자열이어야 합니다.`) |
There was a problem hiding this comment.
타입스크립트는 컴파일 시 타입 에러를 발생시키고, 런타임에서의 타입 안전성을 보장하지 않기 때문에 예외 처리 등을 해야 한다는 걸 덕분에 배웠습니다!!
| @@ -0,0 +1,5 @@ | |||
| const randomString = () => Math.random().toString(36).substring(7).split('').join('.') | |||
| */ | ||
| const initialState = 0 | ||
|
|
||
| export const ACTION_TYPE = { |
There was a problem hiding this comment.
type이나 util은 파일을 분리했는데 왜 상수는 파일을 분리하지 않으신건가요??
Contributor
Author
There was a problem hiding this comment.
type, util 파일을 분리한 곳은 아마 redux를 만든 곳일거에요. 거기는 코드가 조금 많아서 분리하는게 좋다라는 생각이였고, 사용하는 reducer에서는 한 파일에 모두 다 넣었습니다! 사용하는 입장에서 규모가 크지않다면 한 파일로 작성하는게 좋겠다 라는 생각을 했어요!
| @@ -0,0 +1,5 @@ | |||
| const randomString = () => Math.random().toString(36).substring(7).split('').join('.') | |||
|
|
|||
| export const ActionTypes = { | |||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
고민한 것.
useSyncExternalStore라는 외부 스토어를 구독할 수 있는 Hook 덕분이라는것을 알게되었다.배운 점.