Skip to content

refactor(Reanimated): back AnimatedRef with a Shareable instead of a handle - #10413

Merged
tjzel merged 1 commit into
@tjzel/worklets/make-shareable-without-handlefrom
@tjzel/reanimated/animated-ref-mutable
Aug 26, 2026
Merged

tjzel merged 1 commit into
@tjzel/worklets/make-shareable-without-handlefrom
@tjzel/reanimated/animated-ref-mutable

Conversation

@tjzel

@tjzel tjzel commented Aug 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Use plain Shareable as internal implementation of useAnimatedRef.

Test plan

Reanimated runtime tests pass.

Changelog

  • I added an entry to the Unpublished section of each changed package's CHANGELOG.md, or this PR does not change react-native-reanimated or react-native-worklets.

@tjzel
tjzel force-pushed the @tjzel/reanimated/animated-ref-mutable branch from 41f1911 to 30bda5f Compare August 25, 2026 15:47
@coderabbitai

coderabbitai Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d8eae0ac-b555-4ce1-a7bb-65a58401242d

📥 Commits

Reviewing files that changed from the base of the PR and between f30fc59 and 6c81517.

📒 Files selected for processing (1)
  • packages/react-native-reanimated/CHANGELOG.md

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.


📝 Walkthrough

Walkthrough

Animated references now use AnimatedRefOnRN and .value access for UI references. Native serialization stores the shared wrapper directly. Native command dispatch, measurement, and property updates read references through .value. Measurement rejects falsy view tags. The changelog documents these changes.

Merge Risk: 🟡 Moderate · up to 6c815

This refactor changes animated references to use shared state internally, but detached references may retain stale native wrapper state and the changelog describes the migrated type incorrectly. The bounded correctness and documentation issues should be fixed or explicitly accepted before merging.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed The description accurately summarizes the Shareable-based AnimatedRef refactor, test status, and changelog update.
Title check ✅ Passed The title clearly identifies the main change: backing AnimatedRef with a Shareable instead of a handle.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@tjzel
tjzel force-pushed the @tjzel/reanimated/animated-ref-mutable branch from 30bda5f to c1a14ec Compare August 26, 2026 08:16
@tjzel tjzel changed the title refactor(Reanimated): back AnimatedRef with a Mutable instead of a handle refactor(Reanimated): back AnimatedRef with a Shareable instead of a handle Aug 26, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: eeef0486-090d-45a4-b67a-b0103b5300ed

📥 Commits

Reviewing files that changed from the base of the PR and between 30bda5f and c1a14ec.

📒 Files selected for processing (3)
  • packages/react-native-reanimated/CHANGELOG.md
  • packages/react-native-reanimated/src/hook/commonTypes.ts
  • packages/react-native-reanimated/src/hook/useAnimatedRef.native.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@tjzel
tjzel force-pushed the @tjzel/reanimated/animated-ref-mutable branch from c1a14ec to d8171d6 Compare August 26, 2026 08:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a768545c-1556-4be4-91c6-0e08f7a131be

📥 Commits

Reviewing files that changed from the base of the PR and between c1a14ec and d8171d6.

📒 Files selected for processing (1)
  • packages/react-native-reanimated/src/hook/useAnimatedRef.native.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@tjzel
tjzel force-pushed the @tjzel/reanimated/animated-ref-mutable branch from f30fc59 to 6c81517 Compare August 26, 2026 12:26
@tjzel
tjzel merged commit e94bf27 into main Aug 26, 2026
23 checks passed
@tjzel
tjzel deleted the @tjzel/reanimated/animated-ref-mutable branch August 26, 2026 14:28
kirillzyusko added a commit to kirillzyusko/react-native-keyboard-controller that referenced this pull request Oct 5, 2026
## 📜 Description

Fixed crash in `KeyboardChatScrollView` when `extraContentPadding` gets
changed with reanimated 4.7+.

## 💡 Motivation and Context

<!-- Why is this change required? What problem does it solve? -->
<!-- If it fixes an open issue, please link to the issue here. -->

As per
software-mansion/react-native-reanimated#10413
`useAnimatedRef` now returns shared value instead of function.

In this PR we are reflecting latest changes. Mostly this is the same
changes as from
#1656
with one important difference - we moved it to re-usable helper.
Potentially we may try to ask deferred scroll in other places too, so
better to have re-usable block instead of duplicating if-statements
(especially now, when we need to check multiple conditions).

I decided to use `safeScrollTo` everywhere in `useExtraContentPadding` -
mixture of `scrollTo`/`safeScrollTo` would produce more questions, so
let's just be consisitent.

I'm also in the middle of investigation whether it's possible to get rid
off asynchronous code and synchronously modify insets + scroll, but it's
a future work. For now let's just fix a crash 🤞

Closes
#1656
#1655

## 📢 Changelog

<!-- High level overview of important changes -->
<!-- For example: fixed status bar manipulation; added new types
declarations; -->
<!-- If your changes don't affect one of platform/language below - then
remove this platform/language -->

### JS

- added separate `safeScrollTo` handler (in `components/utils` folder);
- handle function/shared value cases in `safeScrollTo` handler;
- added unit tests for `safeScrollTo` handler;
- use `safeScrollTo` instead of `scrollTo` in `useExtraContentPadding`;

## 🤔 How Has This Been Tested?

Tested on Pixel 7 Pro (API 37).

## 📸 Screenshots (if appropriate):

|Before|After|
|-------|-----|
|<video
src="https://github.com/user-attachments/assets/bc6de522-9e17-40ed-9a54-f626362ddac5">|<video
src="https://github.com/user-attachments/assets/51663d93-9a62-44c5-ad45-6e004aecd5fb">|

## 📝 Checklist

- [x] CI successfully passed
- [x] I added new mocks and corresponding unit-tests if library API was
changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants