Setting the file. One moment.
Skill 04 · Vercel React Native Skills
Subchapter 4.25
rules/react-compiler-reanimated-shared-values.mdMarkdown1 KBView on GitHub
With React Compiler enabled, use .get() and .set() instead of reading or
writing .value directly on Reanimated shared values. The compiler can’t track
property access—explicit methods ensure correct behavior.
Incorrect (breaks with React Compiler):
import { useSharedValue } from 'react-native-reanimated'
function Counter() {
const count = useSharedValue(0)
const increment = () => {
count.value = count.value + 1 // opts out of react compiler
}
return <Button onPress={increment} title={`Count: ${count.value}`} />
}Correct (React Compiler compatible):
import { useSharedValue } from 'react-native-reanimated'
function Counter() {
const count = useSharedValue(0)
const increment = () => {
count.set(count.get() + 1)
}
return <Button onPress={increment} title={`Count: ${count.get()}`} />
}See the Reanimated docs (opens in a new tab) for more.