Skip to content

Comments

fix(ios): Reload sandbox when jsBundleSource changes#17

Closed
papay0 wants to merge 1 commit intocallstackincubator:mainfrom
papay0:fix/reload-on-bundle-source-change
Closed

fix(ios): Reload sandbox when jsBundleSource changes#17
papay0 wants to merge 1 commit intocallstackincubator:mainfrom
papay0:fix/reload-on-bundle-source-change

Conversation

@papay0
Copy link

@papay0 papay0 commented Dec 20, 2025

Summary

Fixes an issue where changing the jsBundleSource prop does not reload the sandbox with the new bundle. Previously, when switching between different bundle URLs (e.g., loading different mini-apps), the sandbox would continue showing the first loaded bundle's content.

The Problem

In SandboxReactNativeViewComponentView.mm, the updateProps method:

  1. Updates the delegate's jsBundleSource property when it changes
  2. But does NOT trigger scheduleReactViewLoad
  3. Additionally, loadReactNativeView reuses the existing RCTReactNativeFactory which has already loaded the old bundle

The Fix

  1. Track when jsBundleSource changes
  2. Set self.reactNativeFactory = nil to destroy the cached factory
  3. Call scheduleReactViewLoad to create a new factory with the new bundle URL

Test Plan

  1. Load a sandbox with bundle URL A
  2. Navigate back
  3. Load a sandbox with bundle URL B
  4. Verify bundle B's content is shown (not A's cached content)

Related Issues

This is a critical bug for any use case involving dynamic bundle loading (e.g., mini-app platforms, code push scenarios).

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.
Comment on lines +104 to +106
if (bundleSourceChanged) {
self.reactNativeFactory = nil;
[self scheduleReactViewLoad];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for contribution

Probably recreating factory is overkill here, we simply should reload updated jsBundeUrl i.e. something like RCTTriggerReloadCommandListeners or [RCTBridge reloadWithReason:] would be better

@CAMOBAP
Copy link
Collaborator

CAMOBAP commented Feb 20, 2026

@papay0 thanks a lot for pointing at the problem

#18 - going to replace this PR

@CAMOBAP CAMOBAP closed this Feb 20, 2026
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