[Android] RCTNetInfo "undefined is not an object"
On app startup I call NetInfo.isConnected.fetch().done(this._handleNetworkChange);
which results in a red screen with
undefined is not an object (evaluating 'RCTNetInfo.getCurrentReachability').
NetInfo.isConnected.addEventListener(...) is also called in the same function, with no problems.
NetInfo hasn't been open sourced on Android yet, see http://facebook.github.io/react-native/docs/known-issues.html#content
Ah, my mistake. Looked over that page a few times, but didn't see that.
Hi
Is NetInfo still not available on android? But the docs suggest that it is available. I have upgraded react-native to v0.16.0. But I still see the same message. Can you please clarify?
Thanks Lalith
It should work on Android (https://github.com/facebook/react-native/blob/0.16-stable/Libraries/Network/NetInfo.js) did you add all the permissions to your Manifest?
@cosmith @lalith26 I am also still seeing the error described in this issue although on version v0.16.0. Permissions are added to my manifest. NetInfo is returning undefined on Android.
Looks like it was fixed in 0.17 https://github.com/facebook/react-native/commit/cf892a96d693af778679278549fc8fa354326f43
@cosmith I've just upgraded to 0.17.0 and I can now check on NetInfo if isConnected, but adding a listener for a change doesn't work it doesn't get called, any ideas?
+1, I am also getting the red screen of death. Is it not being open sourced mean that it will always be undefined or is it because I am running RN 15.0? Also is there a workaround of Android.