Skip to content

Commit 31bf986

Browse files
Fix: NetInfo.isConnected for iOS
Properly tear down the reachabilityRef in RCTNetInfo Summary: The pull request that added this (facebook#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).
1 parent 8beb9ac commit 31bf986

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)