Skip to content

Commit 9d07982

Browse files
committed
perf: stabilize cbs
1 parent acc6e0a commit 9d07982

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

package/src/components/Attachment/Audio/AudioAttachment.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
import { PlayPauseButton } from './PlayPauseButton';
1616

1717
import { useTheme } from '../../../contexts';
18+
import { useStableCallback } from '../../../hooks';
1819
import { useStateStore } from '../../../hooks';
1920
import { useAudioPlayer } from '../../../hooks/useAudioPlayer';
2021
import {
@@ -168,14 +169,14 @@ export const AudioAttachment = (props: AudioAttachmentProps) => {
168169
await audioPlayer.stop();
169170
};
170171

171-
const dragStart = () => {
172+
const dragStart = useStableCallback(() => {
172173
audioPlayer.pause();
173-
};
174+
});
174175

175-
const dragEnd = async (currentProgress: number) => {
176+
const dragEnd = useStableCallback(async (currentProgress: number) => {
176177
const positionInSeconds = (currentProgress * duration) / ONE_SECOND_IN_MILLISECONDS;
177178
await audioPlayer.seek(positionInSeconds);
178-
};
179+
});
179180

180181
const onSpeedChangeHandler = async () => {
181182
await audioPlayer.changePlaybackRate();

0 commit comments

Comments
 (0)