Skip to content

Commit

Permalink
Used useSyncedRef
Browse files Browse the repository at this point in the history
  • Loading branch information
dvmoritzschoefl committed Nov 8, 2024
1 parent f3044d0 commit a3eef0a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vis/vishooks/hooks/useTriggerFrame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import * as React from 'react';

import isEqual from 'lodash/isEqual';
import { useSyncedRef } from '../../../hooks/useSyncedRef';

/**
* Hook similar to useEffect that triggers a frame when dependencies change.
Expand All @@ -21,8 +22,7 @@ export function useTriggerFrame(frame: () => void, deps: React.DependencyList, p
const frameRef = React.useRef<number | undefined>(undefined);
const depsRef = React.useRef(deps);

const callbackRef = React.useRef(frame);
callbackRef.current = frame;
const callbackRef = useSyncedRef(frame);

if (!isEqual(depsRef.current, deps)) {
depsRef.current = deps;
Expand Down

0 comments on commit a3eef0a

Please sign in to comment.