From e187b076904de5d283c80145f228fee0d3aa0ea5 Mon Sep 17 00:00:00 2001 From: Mehdi Mulani Date: Mon, 19 Mar 2018 10:51:01 -0700 Subject: [PATCH] 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 --- Libraries/Network/RCTNetInfo.m | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/Network/RCTNetInfo.m b/Libraries/Network/RCTNetInfo.m index afc3d1db3..9b51a5c1a 100644 --- a/Libraries/Network/RCTNetInfo.m +++ b/Libraries/Network/RCTNetInfo.m @@ -164,6 +164,7 @@ RCT_EXPORT_METHOD(getCurrentConnectivity:(RCTPromiseResolveBlock)resolve reject:(__unused RCTPromiseRejectBlock)reject) { SCNetworkReachabilityRef reachability = [self getReachabilityRef]; + SCNetworkReachabilityUnscheduleFromRunLoop(reachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); CFRelease(reachability); resolve(@{@"connectionType": _connectionType ?: RCTConnectionTypeUnknown, @"effectiveConnectionType": _effectiveConnectionType ?: RCTEffectiveConnectionTypeUnknown,