Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Properly tear down the reachabilityRef in RCTNetInfo
Browse files Browse the repository at this point in the history
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).

Reviewed By: PeteTheHeat

Differential Revision: D7322999

fbshipit-source-id: e49ec7311b39920f7b7743a5854c0dda1dbccc73
  • Loading branch information
Mehdi Mulani authored and campsafari committed Apr 11, 2018
1 parent f57401e commit 435f8b9
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions Libraries/Network/RCTNetInfo.m
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ - (BOOL)setReachabilityStatus:(SCNetworkReachabilityFlags)flags
reject:(__unused RCTPromiseRejectBlock)reject)
{
SCNetworkReachabilityRef reachability = [self getReachabilityRef];
SCNetworkReachabilityUnscheduleFromRunLoop(reachability, CFRunLoopGetMain(), kCFRunLoopCommonModes);
CFRelease(reachability);
resolve(@{@"connectionType": _connectionType ?: RCTConnectionTypeUnknown,
@"effectiveConnectionType": _effectiveConnectionType ?: RCTEffectiveConnectionTypeUnknown,
Expand Down

0 comments on commit 435f8b9

Please sign in to comment.