@@ -204,6 +204,7 @@ - (void)setDefaultJSBundle {
204204 // Add built-in items
205205 __weak RCTBridge *bridge = _bridge;
206206 __weak RCTDevSettings *devSettings = _bridge.devSettings ;
207+ __weak RCTDevMenu *weakSelf = self;
207208
208209 [items addObject: [RCTDevMenuItem buttonItemWithTitle: @" Reload" handler: ^{
209210 [bridge reload ];
@@ -296,7 +297,7 @@ - (void)setDefaultJSBundle {
296297 textField.placeholder = @" index" ;
297298 }];
298299 [alertController addAction: [UIAlertAction actionWithTitle: @" Use bundled JS" style: UIAlertActionStyleDefault handler: ^(__unused UIAlertAction *action) {
299- [self setDefaultJSBundle ];
300+ [weakSelf setDefaultJSBundle ];
300301 }]];
301302 [alertController addAction: [UIAlertAction actionWithTitle: @" Use packager location" style: UIAlertActionStyleDefault handler: ^(__unused UIAlertAction *action) {
302303 NSArray * textfields = alertController.textFields ;
@@ -308,7 +309,7 @@ - (void)setDefaultJSBundle {
308309 bundleRoot = @" index" ;
309310 }
310311 if (ipTextField.text .length == 0 && portTextField.text .length == 0 ) {
311- [self setDefaultJSBundle ];
312+ [weakSelf setDefaultJSBundle ];
312313 return ;
313314 }
314315 NSNumberFormatter *formatter = [[NSNumberFormatter alloc ] init ];
@@ -319,8 +320,11 @@ - (void)setDefaultJSBundle {
319320 }
320321 [RCTBundleURLProvider sharedSettings ].jsLocation = [NSString stringWithFormat: @" %@ :%d " ,
321322 ipTextField.text, portNumber.intValue];
322- self->_bridge .bundleURL = [[RCTBundleURLProvider sharedSettings ] jsBundleURLForBundleRoot: bundleRoot fallbackResource: nil ];
323- [self ->_bridge reload ];
323+ __strong RCTBridge *strongBridge = bridge;
324+ if (strongBridge) {
325+ strongBridge.bundleURL = [[RCTBundleURLProvider sharedSettings ] jsBundleURLForBundleRoot: bundleRoot fallbackResource: nil ];
326+ [strongBridge reload ];
327+ }
324328 }]];
325329 [alertController addAction: [UIAlertAction actionWithTitle: @" Cancel" style: UIAlertActionStyleCancel handler: ^(__unused UIAlertAction *action) {
326330 return ;
0 commit comments