From 06bc484840a1d55ebf6bcac12f788a1ecd9de40b Mon Sep 17 00:00:00 2001 From: Arthur Papailhau Date: Sat, 20 Dec 2025 03:30:50 -0800 Subject: [PATCH] fix(ios): Reload sandbox when jsBundleSource changes Previously, changing the `jsBundleSource` prop would update the delegate's bundle URL but not trigger a reload of the React Native view. This caused the sandbox to continue showing the previously loaded bundle's content. The fix: 1. Track when `jsBundleSource` changes in `updateProps` 2. Set `reactNativeFactory = nil` to destroy the cached factory 3. Call `scheduleReactViewLoad` to create a new factory with the new bundle This ensures that loading different bundle URLs (e.g., different mini-apps) correctly loads fresh content each time. --- .../ios/SandboxReactNativeViewComponentView.mm | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/react-native-sandbox/ios/SandboxReactNativeViewComponentView.mm b/packages/react-native-sandbox/ios/SandboxReactNativeViewComponentView.mm index e331077..9025afe 100644 --- a/packages/react-native-sandbox/ios/SandboxReactNativeViewComponentView.mm +++ b/packages/react-native-sandbox/ios/SandboxReactNativeViewComponentView.mm @@ -67,6 +67,9 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & [super updateProps:props oldProps:oldProps]; + // Track if bundle source changed - needs special handling + BOOL bundleSourceChanged = NO; + if (self.reactNativeDelegate) { if (oldViewProps.origin != newViewProps.origin) { [self.reactNativeDelegate setOrigin:newViewProps.origin]; @@ -74,6 +77,7 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & if (oldViewProps.jsBundleSource != newViewProps.jsBundleSource) { [self.reactNativeDelegate setJsBundleSource:newViewProps.jsBundleSource]; + bundleSourceChanged = YES; } if (oldViewProps.allowedTurboModules != newViewProps.allowedTurboModules) { @@ -96,9 +100,13 @@ - (void)updateProps:(const Props::Shared &)props oldProps:(const Props::Shared & [self updateEventEmitterIfNeeded]; } - if (oldViewProps.componentName != newViewProps.componentName || - oldViewProps.initialProperties != newViewProps.initialProperties || - oldViewProps.launchOptions != newViewProps.launchOptions) { + // When bundle source changes, we must destroy the factory to force reload with new bundle + if (bundleSourceChanged) { + self.reactNativeFactory = nil; + [self scheduleReactViewLoad]; + } else if (oldViewProps.componentName != newViewProps.componentName || + oldViewProps.initialProperties != newViewProps.initialProperties || + oldViewProps.launchOptions != newViewProps.launchOptions) { [self scheduleReactViewLoad]; } }