Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix r & d not working from Metro sometimes #47624

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions packages/react-native/React/DevSupport/RCTPackagerConnection.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#import <React/RCTLog.h>
#import <React/RCTPackagerClient.h>
#import <React/RCTReconnectingWebSocket.h>
#import <React/RCTReloadCommand.h>
#import <React/RCTUtils.h>

#if RCT_DEV
Expand All @@ -44,6 +45,7 @@ @implementation RCTPackagerConnection {
NSString *_serverHostPortForSocket;
NSString *_serverSchemeForSocket;
id _bundleURLChangeObserver;
id _reloadWithPotentiallyNewURLObserver;
uint32_t _nextToken;
std::vector<Registration<RCTNotificationHandler>> _notificationRegistrations;
std::vector<Registration<RCTRequestHandler>> _requestRegistrations;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -119,6 +128,8 @@ - (void)stop
}
[[NSNotificationCenter defaultCenter] removeObserver:_bundleURLChangeObserver];
_bundleURLChangeObserver = nil;
[[NSNotificationCenter defaultCenter] removeObserver:_reloadWithPotentiallyNewURLObserver];
_reloadWithPotentiallyNewURLObserver = nil;
_socketConnected = NO;
[_socket stop];
_socket = nil;
Expand Down
Loading