Files
stack/packages/mosaic/framework/skills/vercel-react-native-skills/rules/react-compiler-reanimated-shared-values.md
T
fargo 1a822493ba format: apply repo prettier (3.8.1) to the folded skills tree
963 markdown files reformatted with the repository's pinned prettier so
pnpm format:check covers the folded tree like every other repo file.

The formatter's embedded-language pass also normalized code fences
(TS semicolons, closed HTML tags in examples, lowercased CSS hex colors,
one renumbered list that skipped an index). Alphanumeric token deltas vs
the fold commit were audited file-by-file; all are formatter-equivalent
markup normalizations plus the four sanitized skills.
2026-08-19 14:37:17 -05:00

1.2 KiB

title, impact, impactDescription, tags
title impact impactDescription tags
Use .get() and .set() for Reanimated Shared Values (not .value) LOW required for React Compiler compatibility reanimated, react-compiler, shared-values

Use .get() and .set() for Shared Values with React Compiler

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 for more.