Skip to content

Commit 8f9d86f

Browse files
authored
Perf/#348-B: 불필요한 리렌더링 방지 (#349)
* perf: 불필요한 리렌더링 방지 Refactor: #348 * fix: CI 오류 해결 Resolve: #348
1 parent b0493d3 commit 8f9d86f

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

client/src/components/Workspace/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { WORKSPACE_EVENT } from '@wabinar/constants/socket-message';
22
import Mom from 'components/Mom';
33
import Sidebar from 'components/Sidebar';
4-
import { useEffect, useState } from 'react';
4+
import { useEffect, useMemo, useState } from 'react';
55
import { useParams } from 'react-router-dom';
66
import { getWorkspaceInfo } from 'src/apis/workspace';
77
import MeetingMediaBar from 'src/components/MeetingMediaBar';
@@ -56,11 +56,20 @@ function Workspace() {
5656
};
5757
}, [workspaceSocket]);
5858

59-
if (!momSocket || !workspaceSocket) return <></>;
59+
const memoizedSocketValue = useMemo(
60+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
61+
() => ({ momSocket: momSocket!, workspaceSocket: workspaceSocket! }),
62+
[momSocket, workspaceSocket],
63+
);
64+
65+
const memoizedOnGoingValue = useMemo(
66+
() => ({ isOnGoing, setIsOnGoing }),
67+
[isOnGoing],
68+
);
6069

6170
return (
62-
<SocketContext.Provider value={{ momSocket, workspaceSocket }}>
63-
<MeetingContext.Provider value={{ isOnGoing, setIsOnGoing }}>
71+
<SocketContext.Provider value={memoizedSocketValue}>
72+
<MeetingContext.Provider value={memoizedOnGoingValue}>
6473
{workspace && (
6574
<SelectedMomContext.Provider value={{ selectedMom, setSelectedMom }}>
6675
<Sidebar workspace={workspace} />

0 commit comments

Comments
 (0)