Skip to content

Commit

Permalink
Fix: 호출 오버헤드를 줄이기 위해 커스텀 훅에서 Props 방식으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
luckylooky2 committed Sep 19, 2024
1 parent 9766758 commit 779c0c0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/pages/Call.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const Call = () => {
const [contents, setContents] = useState<any>([]);
const { audio } = useContext(AudioContext);
const { callInfo, dispatch } = useContext(CallContext);
const { disconnectStream } = useStream();
const { stream, disconnectStream } = useStream();
const { socket } = useSocket();
const videos = [
useRef<HTMLVideoElement>(null),
Expand Down Expand Up @@ -420,7 +420,11 @@ const Call = () => {
text={isMuted ? "mute off" : "mute"}
img={isMuted ? "mute.svg" : "mute-off.svg"}
>
<MicrophoneSoundChecker isSmallSize={true} bgColor="lightgray" />
<MicrophoneSoundChecker
stream={stream!}
isSmallSize={true}
bgColor="lightgray"
/>
</CallButton>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/utils/MicrophoneSoundChecker.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { useStream } from "@hooks/useStream";
import { useState, useEffect, FC, useRef } from "react";

interface Props {
stream: MediaStream; // useAudio가 필요없이 호출되는 것을 방지하기 위해 Props로 전환
icon?: boolean;
isSmallSize?: boolean;
bgColor?: string;
}

const MicrophoneSoundChecker: FC<Props> = ({
stream,
icon = false,
isSmallSize = false,
bgColor = "white",
}) => {
const { stream } = useStream();
const [value, setValue] = useState(0);
const divRef = useRef<HTMLDivElement>(null);

Expand Down

0 comments on commit 779c0c0

Please sign in to comment.