Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use RCTBridgeDelegate in the new project template (facebook#23031)
Summary: The main goal of this change is to fix an issue that happens on iOS when the native app starts before the packager server is available which causes app reloads to fail continually until the app is restarted. What happens is that with the current setup we call `RCTBundleURLProvider#jsBundleURLForBundleRoot` once in `AppDelegate#didFinishLaunchingWithOptions`. If at that point the packager server is not running yet it will return nil (expected behaviour) and that will be passed to the bridge constructor. Subsequent reloads will keep trying to load this nil bundle url since it has no way to ask `RCTBundleURLProvider` for a new url now that the packager is actually running. We can fix this by using `RCTBridgeDelegate` instead which is a lot more flexible. Instead of passing the bundle url at construction time it will call the `sourceURLForBridge` method each time the bridge is reloaded. This means that even if the packager is not running yet and that `RCTBundleURLProvider` returns nil for the first invocation, subsequent reloads will call `RCTBundleURLProvider` again for a new value. Changelog: ---------- [iOS] [Added] - Use RCTBridgeDelegate in the new project template Pull Request resolved: facebook#23031 Differential Revision: D13710048 Pulled By: cpojer fbshipit-source-id: 0059c5c962d508737ae410a82315c11ad305efe8
- Loading branch information