[change] remove NetInfo.isConnected.getConnectionInfo()

React Native doesn't have `NetInfo.isConnected.getConnectionInfo()`.
This was incorrectly added to the API while updating the main `NetInfo`
API.

Close #937
This commit is contained in:
Scott Kyle
2018-05-07 22:36:16 -07:00
committed by Nicolas Gallagher
parent 02b6f3ff3c
commit 8b1e6f816f
3 changed files with 11 additions and 7 deletions

View File

@@ -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();

View File

@@ -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);

View File

@@ -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'));
});`
}}