Skip to content

Commit 8b1e6f8

Browse files
appdennecolas
authored andcommitted
[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
1 parent 02b6f3f commit 8b1e6f8

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

packages/react-native-web/src/exports/NetInfo/__tests__/index-test.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ describe('apis/NetInfo', () => {
3737
} catch (e) {}
3838
});
3939

40+
describe('fetch', () => {
41+
test('returns a boolean', done => {
42+
NetInfo.isConnected.fetch().then(isConnected => {
43+
expect(isConnected).toBe(true);
44+
done();
45+
});
46+
});
47+
});
48+
4049
describe('addEventListener', () => {
4150
test('throws if the provided "eventType" is not supported', () => {
4251
expect(() => NetInfo.isConnected.addEventListener('foo', handler)).toThrow();

packages/react-native-web/src/exports/NetInfo/index.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,6 @@ const NetInfo = {
156156
},
157157

158158
fetch(): Promise<boolean> {
159-
console.warn('`fetch` is deprecated. Use `getConnectionInfo` instead.');
160-
return NetInfo.isConnected.getConnectionInfo();
161-
},
162-
163-
getConnectionInfo(): Promise<boolean> {
164159
return new Promise((resolve, reject) => {
165160
try {
166161
resolve(window.navigator.onLine);

website/storybook/2-apis/NetInfo/NetInfoScreen.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ const NetInfoScreen = () => (
107107

108108
<Section title="Properties">
109109
<DocItem
110-
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."
110+
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."
111111
example={{
112-
code: `NetInfo.isConnected.getConnectionInfo().then((isConnected) => {
112+
code: `NetInfo.isConnected.fetch().then((isConnected) => {
113113
console.log('Connection status:', (isConnected ? 'online' : 'offline'));
114114
});`
115115
}}

0 commit comments

Comments
 (0)