animation-with-react-compiler

Animation with React Compiler

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "animation-with-react-compiler" with this command: npx skills add sovranbitcoin/sovran/sovranbitcoin-sovran-animation-with-react-compiler

Animation with React Compiler

Overview

Guidelines for using React Native Reanimated shared values with React Compiler. When using React Compiler, you must use the get() and set() methods instead of directly accessing the value property to ensure compatibility with React Compiler standards.

When to Apply

Reference these guidelines when:

  • Working with React Compiler enabled projects

  • Using useSharedValue in components

  • Accessing or modifying shared value values

  • Ensuring React Compiler compatibility with Reanimated

Key Guideline

Use get() and set() Methods Instead of .value

When working with the React Compiler, you should refrain from accessing and modifying the value property directly. Instead, use the get() and set() methods. They're the alternative API for useSharedValue , compliant with the React Compiler standards.

Don't do this – accessing .value directly:

function 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 }; }

Instead, use get() and set() methods:

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 }; }

Usage Patterns

Reading Shared Values

// ✅ In worklets (useAnimatedStyle, useDerivedValue, etc.) const animatedStyle = useAnimatedStyle(() => { return { opacity: sv.get() }; });

// ✅ In useEffect or callbacks useEffect(() => { console.log(sv.get()); }, []);

Modifying Shared Values

// ✅ 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 }));

Benefits

  • React Compiler Compatible: Works seamlessly with React Compiler

  • Consistent API: Provides a consistent method-based API

  • Type Safety: Better TypeScript support and type inference

  • Future Proof: Aligns with React Compiler standards and best practices

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

animation-with-worklets

No summary provided by upstream source.

Repository SourceNeeds Review
General

react-native-expo

No summary provided by upstream source.

Repository SourceNeeds Review
General

expo-api-routes

No summary provided by upstream source.

Repository SourceNeeds Review
General

zustand-state-management

No summary provided by upstream source.

Repository SourceNeeds Review