Loading...
Loading...
Provides React Native Reanimated guidelines for using shared values with React Compiler. Applies to tasks involving useSharedValue, shared values, React Compiler compatibility, or accessing/modifying shared value values.
npx skill4agent add sovranbitcoin/sovran animation-with-react-compilerget()set()valueuseSharedValuevalueget()set()useSharedValue.valuefunction App() {
const sv = useSharedValue(100);
const animatedStyle = useAnimatedStyle(() => {
"worklet";
return { width: sv.value * 100 }; // ❌ Direct property access
});
const handlePress = () => {
sv.value = sv.value + 1; // ❌ Direct property modification
};
}get()set()function App() {
const sv = useSharedValue(100);
const animatedStyle = useAnimatedStyle(() => {
"worklet";
return { width: sv.get() * 100 }; // ✅ Using get() method
});
const handlePress = () => {
sv.set((value) => value + 1); // ✅ Using set() method
};
}// ✅ In worklets (useAnimatedStyle, useDerivedValue, etc.)
const animatedStyle = useAnimatedStyle(() => {
return { opacity: sv.get() };
});
// ✅ In useEffect or callbacks
useEffect(() => {
console.log(sv.get());
}, []);// ✅ Direct value assignment
sv.set(100);
// ✅ Using updater function
sv.set((currentValue) => currentValue + 1);
// ✅ With animation functions
sv.set(withSpring(1.2));
sv.set(withTiming(0.8, { duration: 300 }));