Skip to content

Commit

Permalink
[change] remove NetInfo.isConnected.getConnectionInfo()
Browse files Browse the repository at this point in the history
React Native doesn't have `NetInfo.isConnected.getConnectionInfo()`.
This was incorrectly added to the API while updating the main `NetInfo`
API.

Close #937
  • Loading branch information
appden authored and necolas committed May 8, 2018
1 parent 02b6f3f commit 8b1e6f8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ describe('apis/NetInfo', () => {
} catch (e) {}
});

describe('fetch', () => {
test('returns a boolean', done => {
NetInfo.isConnected.fetch().then(isConnected => {
expect(isConnected).toBe(true);
done();
});
});
});

describe('addEventListener', () => {
test('throws if the provided "eventType" is not supported', () => {
expect(() => NetInfo.isConnected.addEventListener('foo', handler)).toThrow();
Expand Down
5 changes: 0 additions & 5 deletions packages/react-native-web/src/exports/NetInfo/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,6 @@ const NetInfo = {
},

fetch(): Promise<boolean> {
console.warn('`fetch` is deprecated. Use `getConnectionInfo` instead.');
return NetInfo.isConnected.getConnectionInfo();
},

getConnectionInfo(): Promise<boolean> {
return new Promise((resolve, reject) => {
try {
resolve(window.navigator.onLine);
Expand Down
4 changes: 2 additions & 2 deletions website/storybook/2-apis/NetInfo/NetInfoScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ const NetInfoScreen = () => (

<Section title="Properties">
<DocItem
description="An object with the same methods as above but the listener receives a boolean which represents the internet connectivity. Use this if you are only interested with whether the device has internet connectivity."
description="An object with similar methods as above but the listener receives a boolean which represents the internet connectivity. Use this if you are only interested with whether the device has internet connectivity."
example={{
code: `NetInfo.isConnected.getConnectionInfo().then((isConnected) => {
code: `NetInfo.isConnected.fetch().then((isConnected) => {
console.log('Connection status:', (isConnected ? 'online' : 'offline'));
});`
}}
Expand Down

0 comments on commit 8b1e6f8

Please sign in to comment.