Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getCurrentConnectivity should resolve with object #6373

Closed
wants to merge 2 commits into from
Closed

getCurrentConnectivity should resolve with object #6373

wants to merge 2 commits into from

Conversation

mrlaessig
Copy link
Contributor

getCurrentConnectivity() should resolve with object instead of array otherwise in NetInfo.fetch().done(reach => console.log('Initial: ' + reach)) reach will be undefined (see https://github.com/l-urence/react-native/blob/master/Libraries/Network/NetInfo.js#L200).

cc @satya164

@facebook-github-bot
Copy link
Contributor

By analyzing the blame information on this pull request, we identified @satya164, @nicklockwood and @vjeux to be potential reviewers.

@facebook-github-bot facebook-github-bot added GH Review: review-needed CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. labels Mar 9, 2016
@mrlaessig
Copy link
Contributor Author

As far as I can see Android looks good. But never tested.

@corbt
Copy link
Contributor

corbt commented Mar 9, 2016

I've also noticed that NetInfo.fetch appears broken currently, and it looks like this should fix it. Do you have a test plan? Perhaps a code sample that shows how it was broken before and now works? Thanks for this!

@corbt corbt mentioned this pull request Mar 9, 2016
7 tasks
@satya164
Copy link
Contributor

satya164 commented Mar 9, 2016

cc @bestander @nicklockwood

@corbt
Copy link
Contributor

corbt commented Mar 9, 2016

I think NetInfo.fetch was just forgotten in c9a1956. Probably would be worth looking for calls to RCTPromiseResolveBlock and making sure nothing else was missed.

@satya164
Copy link
Contributor

satya164 commented Mar 9, 2016

ccing @dmmiller too

@mrlaessig
Copy link
Contributor Author

Apparently all other RCTPromiseResolveBlock calls are okay or at least they do not return an array (find . -name *.m | xargs egrep 'resolve\(').

@corbt The code should now work as described in the documentation.

@corbt
Copy link
Contributor

corbt commented Mar 9, 2016

sweet, thanks again for working on this @l-urence.

@facebook-github-bot shipit

@facebook-github-bot
Copy link
Contributor

Thanks for importing. If you are an FB employee go to Phabricator to review.

@ghost ghost closed this in 336dbe4 Mar 10, 2016
@dmmiller
Copy link

Thanks for catching this one.

@dmmiller dmmiller reopened this Mar 10, 2016
@dmmiller dmmiller closed this Mar 10, 2016
@mrlaessig mrlaessig deleted the fix-netinfo-fetch branch March 10, 2016 13:46
bestander pushed a commit that referenced this pull request Mar 15, 2016
Summary:`getCurrentConnectivity()` should resolve with object instead of array otherwise in `NetInfo.fetch().done(reach => console.log('Initial: ' + reach))` `reach` will be undefined (see https://github.com/l-urence/react-native/blob/master/Libraries/Network/NetInfo.js#L200).

cc satya164
Closes #6373

Differential Revision: D3032773

fb-gh-sync-id: edc545548d3c17387545b6c59894c27e4563cb18
shipit-source-id: edc545548d3c17387545b6c59894c27e4563cb18
@shraddha1704
Copy link

I upgraded to 0.22 today. I am getting the following error:
undefined is not an object (evaluating 'RCTNetInfo.getCurrentConnectivity().then')

@bestander
Copy link
Contributor

@shraddha1704 this PR was picked into 0.22 release.
Try creating a new issue with more details please

@shraddha1704
Copy link

Found a solution. Replacing the fetch function in NetInfo.js with:
fetch(): Promise {
return new Promise((resolve, reject) => {
RCTNetInfo.getCurrentConnectivity(
function(resp) {
resolve(resp.network_info);
},
reject
);
});
},

@satya164
Copy link
Contributor

@shraddha1704 Your native code seems to be out of date. Run react-native upgrade to update your native files.

matt-oakes pushed a commit to matt-oakes/react-native that referenced this pull request Feb 7, 2019
Summary:`getCurrentConnectivity()` should resolve with object instead of array otherwise in `NetInfo.fetch().done(reach => console.log('Initial: ' + reach))` `reach` will be undefined (see https://github.com/l-urence/react-native/blob/master/Libraries/Network/NetInfo.js#L200).

cc satya164
Closes facebook#6373

Differential Revision: D3032773

fb-gh-sync-id: edc545548d3c17387545b6c59894c27e4563cb18
shipit-source-id: edc545548d3c17387545b6c59894c27e4563cb18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants