react-native icon indicating copy to clipboard operation
react-native copied to clipboard

[Android] RCTNetInfo "undefined is not an object"

Open madwed opened this issue 11 years ago • 8 comments

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.

madwed avatar Nov 10 '15 16:11 madwed

NetInfo hasn't been open sourced on Android yet, see http://facebook.github.io/react-native/docs/known-issues.html#content

cosmith avatar Nov 10 '15 17:11 cosmith

Ah, my mistake. Looked over that page a few times, but didn't see that.

madwed avatar Nov 10 '15 18:11 madwed

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

lalith26 avatar Dec 11 '15 16:12 lalith26

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 avatar Dec 14 '15 08:12 cosmith

@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.

fender avatar Dec 18 '15 09:12 fender

Looks like it was fixed in 0.17 https://github.com/facebook/react-native/commit/cf892a96d693af778679278549fc8fa354326f43

cosmith avatar Dec 19 '15 11:12 cosmith

@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?

jonolock91 avatar Dec 22 '15 11:12 jonolock91

+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.

tuneZola avatar Jan 25 '16 23:01 tuneZola