fix: use TurboModuleRegistry as primary lookup to support RN 0.79+ bridgeless mode#657
Merged
Merged
Conversation
…idgeless mode In bridgeless mode (RN 0.79+, Expo SDK 54+), `__turboModuleProxy` is not installed as a global, so the previous heuristic fell through to `NativeModules.RNViewShot` which is also unavailable (zero-key object in bridgeless mode). Replace both paths with `TurboModuleRegistry.get()` as the primary resolver and `NativeModules.RNViewShot` as a fallback for old architecture compatibility. Fixes #653. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR changes the native module resolution path for RNViewShot so JS attempts React Native’s TurboModuleRegistry lookup before falling back to legacy NativeModules.
Changes:
- Removes the
global.__turboModuleProxyheuristic. - Uses
TurboModuleRegistry.get("RNViewShot")as the primary resolver. - Keeps
NativeModules.RNViewShotas the legacy fallback.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
global.__turboModuleProxyheuristicTurboModuleRegistry.get()as the primary resolver (the correct stable API for both old and new arch)NativeModules.RNViewShotas the legacy fallbackBackground
The previous code used
global.__turboModuleProxy != nullas a gate to decide betweenTurboModuleRegistry.getEnforcing()andNativeModules.RNViewShot. In RN 0.79+ bridgeless mode,__turboModuleProxyis null, so it fell through toNativeModules.RNViewShot— which is also absent in bridgeless (0 keys). This caused:TurboModuleRegistry.get()is the correct API for module resolution in both old and new arch, including most bridgeless setups.Scope / Known Limitations
This PR fixes the JS-side module lookup heuristic. However, in fully bridgeless runtimes (RN 0.81 + Expo SDK 54, where
global.RN$UnifiedNativeModuleProxy === true), runtime evidence showsTurboModuleRegistry.get('RNViewShot')itself returnsnull. This appears to be because the iOS native implementation depends onself.bridge.uiManager addUIBlock:— a bridge-only API — which prevents the TurboModule from initializing without a bridge. Full bridgeless support would require migrating the iOS view-lookup path away fromRCTUIManager, which is tracked in #653 as a separate larger effort.Related: #653
Test plan
captureRefstill workscaptureRefstill works🤖 Generated with Claude Code