diff --git a/packages/react-native/React/DevSupport/RCTPackagerConnection.mm b/packages/react-native/React/DevSupport/RCTPackagerConnection.mm index bd4075ca1b3294..39419d60e12036 100644 --- a/packages/react-native/React/DevSupport/RCTPackagerConnection.mm +++ b/packages/react-native/React/DevSupport/RCTPackagerConnection.mm @@ -20,6 +20,7 @@ #import #import #import +#import #import #if RCT_DEV @@ -44,6 +45,7 @@ @implementation RCTPackagerConnection { NSString *_serverHostPortForSocket; NSString *_serverSchemeForSocket; id _bundleURLChangeObserver; + id _reloadWithPotentiallyNewURLObserver; uint32_t _nextToken; std::vector> _notificationRegistrations; std::vector> _requestRegistrations; @@ -78,6 +80,13 @@ - (instancetype)init usingBlock:^(NSNotification *_Nonnull __unused note) { [weakSelf bundleURLSettingsChanged]; }]; + _reloadWithPotentiallyNewURLObserver = + [[NSNotificationCenter defaultCenter] addObserverForName:RCTTriggerReloadCommandNotification + object:nil + queue:[NSOperationQueue mainQueue] + usingBlock:^(NSNotification *_Nonnull __unused note) { + [weakSelf bundleURLSettingsChanged]; + }]; } return self; } @@ -119,6 +128,8 @@ - (void)stop } [[NSNotificationCenter defaultCenter] removeObserver:_bundleURLChangeObserver]; _bundleURLChangeObserver = nil; + [[NSNotificationCenter defaultCenter] removeObserver:_reloadWithPotentiallyNewURLObserver]; + _reloadWithPotentiallyNewURLObserver = nil; _socketConnected = NO; [_socket stop]; _socket = nil;