-
Notifications
You must be signed in to change notification settings - Fork 2
모달 내 소켓 통신을 위한 useSocketStore 생성 및 적용 #238
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
d497069
✨feat: useSocketStore 생성
kim-hyunjoo bf89f85
♻️refactor: 닉네임 변경 모달에서 sendMessage 사용하도록 변경
kim-hyunjoo 8e793b4
🎨format: setSendMessage null도 가능하도록 변경
kim-hyunjoo c5fa60a
♻️refactor: 게임 변경 핸들러에서 직접 sendMessage 하도록 변경
kim-hyunjoo 79bc04c
🎨format: 사용되지 않는 set 함수 삭제
kim-hyunjoo fa19bd1
🎨format: 의존성 배열에서 setSendMessage 삭제
kim-hyunjoo 933b197
🎨format: 의존성 배열에서 setHostName 삭제
kim-hyunjoo 689ab22
♻️refactor: sendMessage useCallback으로 감싸기
kim-hyunjoo 53bbc98
Merge branch 'dev' of https://github.com/Team-groupHi/grouphi-mvp-fe …
kim-hyunjoo 9889e67
🎨format: closeModal 맨 아래로 이동
kim-hyunjoo 8d23ae7
Merge branch 'dev' of https://github.com/Team-groupHi/grouphi-mvp-fe …
kim-hyunjoo a00f0e4
🐛fix: 누락된 병합 과정 추가
kim-hyunjoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import * as StompJS from '@stomp/stompjs'; | ||
| import { create } from 'zustand'; | ||
|
|
||
| interface SocketStoreProps { | ||
| sendMessage: | ||
| | (<T>(params: Omit<StompJS.IPublishParams, 'body'> & { body?: T }) => void) | ||
| | null; | ||
| setSendMessage: ( | ||
| sendFn: | ||
| | (<T>( | ||
| params: Omit<StompJS.IPublishParams, 'body'> & { body?: T } | ||
| ) => void) | ||
| | null | ||
| ) => void; | ||
| } | ||
|
|
||
| const useSocketStore = create<SocketStoreProps>((set) => ({ | ||
| sendMessage: null, | ||
| setSendMessage: (sendFn) => set({ sendMessage: sendFn }), | ||
| })); | ||
|
|
||
| export default useSocketStore; |
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.
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.
setSendMessage함수는 Zustand store에서 반환된 setter 함수로, 컴포넌트의 생명주기 동안 항상 동일한 참조를 유지합니다. 따라서useEffect의 의존성 배열에 포함하지 않아도 괜찮습니다. 의존성 배열을 간소화하여 코드 가독성을 높이고 불필요한 재실행 가능성을 줄일 수 있습니다.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.
완료