Skip to content

Commit e187b07

Browse files
Mehdi Mulanigrabbou
authored andcommitted
Properly tear down the reachabilityRef in RCTNetInfo
Summary: The pull request that added this (#17397) simply forgot to remove the callback, which would cause crashes if the RCTNetInfo module was ever deallocated. While that usually doesn't happen in apps, it can if the user logs out and you need to wipe all the RCT modules (to remove user data, for instance). Reviewed By: PeteTheHeat Differential Revision: D7322999 fbshipit-source-id: e49ec7311b39920f7b7743a5854c0dda1dbccc73
1 parent 2845a86 commit e187b07

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

Libraries/Network/RCTNetInfo.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ - (BOOL)setReachabilityStatus:(SCNetworkReachabilityFlags)flags
164164
reject:(__unused RCTPromiseRejectBlock)reject)
165165
{
166166
SCNetworkReachabilityRef reachability = [self getReachabilityRef];
167+
SCNetworkReachabilityUnscheduleFromRunLoop(reachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
167168
CFRelease(reachability);
168169
resolve(@{@"connectionType": _connectionType ?: RCTConnectionTypeUnknown,
169170
@"effectiveConnectionType": _effectiveConnectionType ?: RCTEffectiveConnectionTypeUnknown,

0 commit comments

Comments
 (0)