Skip to content

Commit

Permalink
Merge pull request #2040 from Shopify/integration
Browse files Browse the repository at this point in the history
Fix reset of useClock value on component re-rendering (#2038)
  • Loading branch information
lozovskijaleksej committed Dec 10, 2023
2 parents a7760c4 + e66b9ae commit 9c6f9e2
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions package/src/external/reanimated/interpolators.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import type { ExtrapolationType, SharedValue } from "react-native-reanimated";
import { useMemo } from "react";
import type {
ExtrapolationType,
FrameInfo,
SharedValue,
} from "react-native-reanimated";
import { useMemo, useRef } from "react";

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

export const useClock = () => {
const clock = useSharedValue(0);
useFrameCallback((info) => {
const callback = useRef((info: FrameInfo) => {
"worklet";
clock.value = info.timeSinceFirstFrame;
});
}).current;
useFrameCallback(callback);
return clock;
};

Expand Down

0 comments on commit 9c6f9e2

Please sign in to comment.