Skip to content

Commit d3c1b95

Browse files
authored
Merge pull request #2040 from Shopify/integration
Fix reset of useClock value on component re-rendering (#2038)
2 parents 4328153 + 78d85f9 commit d3c1b95

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

package/src/external/reanimated/interpolators.ts

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import type { ExtrapolationType, SharedValue } from "react-native-reanimated";
2-
import { useMemo } from "react";
1+
import type {
2+
ExtrapolationType,
3+
FrameInfo,
4+
SharedValue,
5+
} from "react-native-reanimated";
6+
import { useMemo, useRef } from "react";
37

48
import type { SkPath, SkPoint } from "../../skia/types";
59
import { interpolatePaths, interpolateVector } from "../../animation";
@@ -19,9 +23,11 @@ export const notifyChange = (value: SharedValue<unknown>) => {
1923

2024
export const useClock = () => {
2125
const clock = useSharedValue(0);
22-
useFrameCallback((info) => {
26+
const callback = useRef((info: FrameInfo) => {
27+
"worklet";
2328
clock.value = info.timeSinceFirstFrame;
24-
});
29+
}).current;
30+
useFrameCallback(callback);
2531
return clock;
2632
};
2733

0 commit comments

Comments
 (0)