Skip to content

Commit

Permalink
fix(useAutoPlay): use useCallback
Browse files Browse the repository at this point in the history
  • Loading branch information
EldarMuhamethanov committed Nov 5, 2024
1 parent d94fc96 commit b361dc4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/vkui/src/components/Gallery/hooks.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { useCallback } from 'react';
import * as React from 'react';
import { useStableCallback } from '../../hooks/useStableCallback';
import { useDOM } from '../../lib/dom';
Expand All @@ -18,8 +19,8 @@ export function useAutoPlay({ timeout, slideIndex, onNext }: AutoPlayConfig): {
const timeoutRef = React.useRef<TimeoutId>(null);
const callbackFn = useStableCallback(onNext);

const pause = useStableCallback(() => setPaused(true));
const resume = useStableCallback(() => setPaused(false));
const pause = useCallback(() => setPaused(true), []);
const resume = useCallback(() => setPaused(false), []);

// Выносим функции очистки и старта таймера в отдельные функции
const clearAutoPlayTimeout = React.useCallback(() => {
Expand Down

0 comments on commit b361dc4

Please sign in to comment.