Skip to content

Commit

Permalink
Update useOnCellActiveAnimation.ts
Browse files Browse the repository at this point in the history
[Reanimated] Tried to modify key `current` of an object which has been already passed to a worklet

computerjazz#539
  • Loading branch information
dmk3141618 authored Dec 5, 2024
1 parent ef4e35b commit b668316
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/hooks/useOnCellActiveAnimation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useRef } from "react";
import { useEffect } from "react";
import Animated, {
useDerivedValue,
useSharedValue,
withSpring,
WithSpringConfig,
} from "react-native-reanimated";
Expand All @@ -15,8 +16,11 @@ type Params = {
export function useOnCellActiveAnimation(
{ animationConfig }: Params = { animationConfig: {} }
) {
const animationConfigRef = useRef(animationConfig);
animationConfigRef.current = animationConfig;
const animationConfigRef = useSharedValue(animationConfig);

useEffect(() => {
animationConfigRef.value = animationConfig;
}, [animationConfig]);

const isActive = useIsActive();

Expand All @@ -26,8 +30,8 @@ export function useOnCellActiveAnimation(
const toVal = isActive && isTouchActiveNative.value ? 1 : 0;
return withSpring(toVal, {
...DEFAULT_ANIMATION_CONFIG,
...animationConfigRef.current,
});
...animationConfigRef.value,
} as WithSpringConfig);
}, [isActive]);

return {
Expand Down

0 comments on commit b668316

Please sign in to comment.