Skip to content

fix(react-native/ios): attach a recycled NativeScriptUIView's handle when it matches its last one - #80

Merged
ammarahm-ed merged 1 commit into
android-react-nativefrom
fix/rn-ios-recycled-view
Oct 25, 2026
Merged

ammarahm-ed merged 1 commit into
android-react-nativefrom
fix/rn-ios-recycled-view

Conversation

@NathanWalker

Copy link
Copy Markdown
Contributor

Split out of #77 (item 1 of the "NativeScript bugs" list in ng-native/ng-native#931).

Summary

A recycled NativeScriptUIView stayed empty when it was remounted with the handle it last showed. Fabric keeps _props across prepareForRecycle, while the container is cleared, so diffing against _props saw no handle change and never re-attached the view.

 updateProps(props, oldProps)
-  old = _props
+  old = oldProps ?? defaultProps   // RCTMountingManager passes nullptr on a fresh mount
   if old.nativeViewHandle != new.nativeViewHandle
     setNativeViewHandle(new)

_props itself is left alone, because RN's own prepareForRecycle diffs layer state against it.

Evidence

iOS 26.5 simulator, Debug, RN 0.86.3 / Expo. The same commit was tested in #77, cherry-picked here unchanged.

  • Before: unmount and remount a NativeScriptUIView with the same handle, and the red view does not come back (superview is nil).
  • After: the red view returns and superview is set.

Merge Danger

Door: two-way

Blast Radius: iOS NativeScriptUIView only

A fresh mount passes oldProps == nullptr, which now maps to the default props, so first mounts attach exactly as before.

…when it matches its last one

Fabric keeps _props across prepareForRecycle while the container is
cleared, so diffing against _props skipped setNativeViewHandle when a
recycled host was mounted with the handle it last showed, leaving it
empty. Diff against the oldProps argument instead, which is null on a
fresh mount.
@coderabbitai

coderabbitai Bot commented Oct 24, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ea435a7b-4ab2-41e3-ba24-152a4685295a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@ammarahm-ed
ammarahm-ed merged commit e483aef into android-react-native Oct 25, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants