Optimize animations for React Compiler and reduced motion#123
Conversation
📝 WalkthroughWalkthroughThis PR systematically updates React Native Reanimated usage across multiple animation components by migrating from deprecated ChangesReanimated API migration and reduced-motion accessibility
Estimated code review effort🎯 4 (Complex) | ⏱️ ~60 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
package.json (1)
28-28: ⚡ Quick winPin
react-compiler-healthcheckto a specific version instead of@latest.Using
@latestcreates a floating dependency that can introduce non-deterministic behavior in CI/CD and make it difficult to reproduce issues. All other dependencies in this file use pinned or constrained semver ranges (exact,^, or~). For a tool that verifies compiler compatibility—where consistency is critical—pinning to a specific version ensures reproducible builds and prevents unexpected breaking changes.Consider replacing
@latestwith a pinned version (e.g.,react-compiler-healthcheck@0.0.1) or at least a tighter range like^0.0.1.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@package.json` at line 28, The react-compiler-healthcheck dependency in the check:compiler script uses `@latest` which creates a floating dependency, causing non-deterministic behavior and making CI/CD builds non-reproducible. Replace `@latest` with either a pinned version (e.g., `@0.0.1`) or a constrained semver range (e.g., @^0.0.1) to match the pattern used by other dependencies in the file and ensure consistency and reproducibility in builds.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@package.json`:
- Line 28: The check:compiler script references the deprecated
react-compiler-healthcheck@latest tool which is no longer available on npm and
has been removed from official React documentation. Remove the check:compiler
script from package.json entirely, as the modern approach uses
eslint-plugin-react-compiler for analysis in the editor and verification through
React DevTools or build output inspection, rather than a dedicated CLI
healthcheck tool. If you want to keep static analysis, install and configure
eslint-plugin-react-compiler in your ESLint configuration instead.
---
Nitpick comments:
In `@package.json`:
- Line 28: The react-compiler-healthcheck dependency in the check:compiler
script uses `@latest` which creates a floating dependency, causing
non-deterministic behavior and making CI/CD builds non-reproducible. Replace
`@latest` with either a pinned version (e.g., `@0.0.1`) or a constrained semver
range (e.g., @^0.0.1) to match the pattern used by other dependencies in the
file and ensure consistency and reproducibility in builds.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: cc61e177-dae6-4a6e-b24a-110c09f4541c
📒 Files selected for processing (2)
package.jsonsrc/features/learning-plans/quiz-step.tsx
e8ad935 to
a71ff44
Compare
|
Verified the review findings. Updated the PR title. Kept the healthcheck command because it remains documented for Expo, is available on npm, and the repo already has compiler lint rules configured. Kept |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/app/notifications.tsx`:
- Around line 68-71: Animations are currently applied unconditionally without
respecting the user's reduced-motion preferences. Add the `useReducedMotion()`
hook at the top of the component to detect when reduced motion is enabled, then
conditionally gate all animation transitions. For the `NOTIFICATION_EXIT` fade
animation and `NOTIFICATION_LAYOUT` spring animation constants, apply them only
when reduced motion is disabled (when the hook returns false). Similarly, update
all `withTiming` and `withSpring` animation calls in the tab timing and swipe
delete handlers to skip animations when reduced motion is enabled, snapping to
the final state immediately instead. Finally, conditionally apply the `exiting`
and `layout` props on `Animated.View` only when reduced motion is not enabled,
ensuring a seamless experience for all users.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: dca9fd92-f0ca-4f58-afe2-69bcb2cb5444
📒 Files selected for processing (5)
src/app/(app)/home.tsxsrc/app/notifications.tsxsrc/components/Mascot.tsxsrc/components/bottom-nav.tsxsrc/features/learning-plans/learning-plan-ui.tsx
|
@Gamius00 Ready to merge |
Summary
pnpm check:compilerand confirms Expo's React Compiler setup across the application.valueaccess toget()andset()Why
React Compiler can reduce React render work, but it does not reduce UI-thread animation work or the number of native views updated each frame. The previous analysis loader continuously transformed nine separate views and scheduled each cycle from JavaScript. Several Reanimated paths also used direct shared-value property access, which is not the Compiler-aligned API.
This change keeps the existing lightweight interaction architecture while reducing continuous loader work, improving animation cleanup and accessibility, and making shared-value access compatible with React Compiler assumptions.
User impact
Validation
pnpm lintpnpm typecheckpnpm test- 18 files, 72 tests passedpnpm check:compiler- 94/94 components compiled; no incompatible librariespnpm format:checkpnpm exec expo export --platform android --output-dir .tmp-animation-export- production Android bundle completed successfully with 7,481 modulesSummary by CodeRabbit
Chores
Improvements