Skip to content

Commit 9260b2c

Browse files
committed
fix: [FN-273] 동일 참조 문제 해결
1 parent 2b5756e commit 9260b2c

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/shared/socket/useYjs.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function useYjs(options: UseYjsOptions) {
1616
const [connectionError, setConnectionError] = useState<string | null>(null);
1717
const [cards, setCards] = useState<CardData[]>([]);
1818
const [awarenessStates, setAwarenessStates] = useState<Map<number, unknown>>(
19-
new Map()
19+
new Map(),
2020
);
2121

2222
const providerRef = useRef<YjsProvider | null>(null);
@@ -40,28 +40,28 @@ export function useYjs(options: UseYjsOptions) {
4040

4141
// Awareness 변경 리스너 설정
4242
provider.onAwarenessChange((states) => {
43-
setAwarenessStates(states);
43+
setAwarenessStates(Object.assign({}, states));
4444
});
4545

4646
// 초기 카드 로드
4747
setCards(provider.getCards());
4848

4949
// 초기 Awareness 로드
50-
setAwarenessStates(provider.getAwarenessStates());
50+
setAwarenessStates(Object.assign({}, provider.getAwarenessStates()));
5151

5252
return true;
5353
}
5454
return false;
5555
} catch (error) {
5656
setConnectionError(
57-
error instanceof Error ? error.message : "Connection failed"
57+
error instanceof Error ? error.message : "Connection failed",
5858
);
5959
setIsConnected(false);
6060
setHasAccess(false);
6161
return false;
6262
}
6363
},
64-
[cardsetId, userId, token]
64+
[cardsetId, userId, token],
6565
);
6666

6767
const disconnect = useCallback(() => {
@@ -81,7 +81,7 @@ export function useYjs(options: UseYjsOptions) {
8181
}
8282
return "";
8383
},
84-
[]
84+
[],
8585
);
8686

8787
const deleteCard = useCallback((index: number) => {
@@ -106,13 +106,13 @@ export function useYjs(options: UseYjsOptions) {
106106
(
107107
field: "question" | "answer",
108108
cardIndex: number,
109-
cursor?: { index: number; length: number }
109+
cursor?: { index: number; length: number },
110110
) => {
111111
if (providerRef.current?.getHasAccess()) {
112112
providerRef.current.setAwareness(field, cardIndex, cursor);
113113
}
114114
},
115-
[]
115+
[],
116116
);
117117

118118
const getCardQuestionText = useCallback((index: number) => {

0 commit comments

Comments
 (0)