fix: use animated theme with scoped themes#1178
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/unistyles/src/reanimated/useAnimatedTheme.native.ts`:
- Around line 20-30: The change listener in useEffect currently returns early
when scopedTheme is truthy, preventing updates; remove the guard that checks
scopedTheme inside the StyleSheet.addChangeListener callback so that when
changedDependencies includes UnistyleDependency.Theme you always call
theme.set(UnistylesRuntime.getTheme()) (i.e. update the logic around
StyleSheet.addChangeListener in useEffect to not skip refreshes when scopedTheme
is present).
In `@packages/unistyles/src/reanimated/useAnimatedTheme.ts`:
- Around line 21-28: The hook currently ignores theme events when scopedTheme is
truthy, preventing later scoped-theme updates from reaching animated consumers;
in the useEffect listener callback (where services.listener.addListeners is
registered for UnistyleDependency.Theme) remove the early return that checks
scopedTheme and always call theme.set(UnistylesRuntime.getTheme()) on each event
so the runtime-resolved theme (via UnistylesRuntime.getTheme) refreshes animated
consumers even inside ScopedTheme.
🪄 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: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 8d2e52ec-19f7-49d6-b9c3-2a9360146aa1
📒 Files selected for processing (2)
packages/unistyles/src/reanimated/useAnimatedTheme.native.tspackages/unistyles/src/reanimated/useAnimatedTheme.ts
Summary
Fixes #1177
Summary by CodeRabbit