-
Notifications
You must be signed in to change notification settings - Fork 394
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
[v5] Cusomisation options & removal of deprecated methods #230
Conversation
README.md
Outdated
```javascript | ||
NetInfo.configure({ | ||
reachabilityUrl: 'https://clients3.google.com/generate_204', | ||
reachabilityTest: response => response.status === 204, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should be an async/await function
reachabilityTest: async response => await response.status === 204,
because TS is complaining "Type 'boolean' is not assignable to type 'Promise'.ts(2322)"
@matt-oakes I just tried changing the export function useNetInfo(
userConfig?: Partial<Types.NetInfoConfiguration>,
): Types.NetInfoState {
if (userConfig) {
configure(userConfig);
}
// ... same code
const [netInfo, setNetInfo] = useState<Types.NetInfoState>({
type: Types.NetInfoStateType.unknown,
isConnected: false,
isInternetReachable: false,
details: null,
});
useEffect((): (() => void) => {
return addEventListener(setNetInfo);
}, []);
return netInfo;
} In my app export default function OtherScreen() {
const { isConnected, type } = useNetInfo({
reachabilityUrl: 'http://detectportal.firefox.com',
reachabilityTest: async response => (await response.text()) === 'success',
});
....
}
|
this looks really good, any idea on when this might be released? |
I still need to do some work on this before I can release it. See the list above for details. |
README.md
Outdated
NetInfo.configure({ | ||
reachabilityUrl: 'https://clients3.google.com/generate_204', | ||
reachabilityTest: response => response.status === 204, | ||
reachabilityShortTimeout: 60 * 1000, // 60s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reachabilityShortTimeout: 60 * 1000, // 60s | |
reachabilityShortTimeout: 5 * 1000, // 5s |
README.md
Outdated
reachabilityUrl: 'https://clients3.google.com/generate_204', | ||
reachabilityTest: response => response.status === 204, | ||
reachabilityShortTimeout: 60 * 1000, // 60s | ||
reachabilityLongTimeout: 5 * 1000, // 5s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reachabilityLongTimeout: 5 * 1000, // 5s | |
reachabilityLongTimeout: 60 * 1000, // 60s |
…aded the example project to RN 0.61.2
67f832c
to
e87181e
Compare
# [5.0.0](v4.7.0...v5.0.0) (2019-12-08) ### Features * Configuration & removal of deprecated methods ([#230](#230)) ([fab577d](fab577d)) ### BREAKING CHANGES * Previously deprecated methods have not been removed. These methods have been deprecated since this library was extracted from the core of React Native. Most users will not have any issues with migrating if they were not ignoring the previous warnings. Added a new way to configure the reachability URL that the library uses on iOS to check for an internet connection. The default is still to use the Google Chrome URL, however, you can now customise this URL, test function, and the timeouts that are used.
🎉 This PR is included in version 5.0.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
Overview
This PR is for the future 5.0.0 release. The main changes are:
Breaking changes:
fetch()
.How to test this
yarn add @react-native-community/netinfo@next
or
npm install --save @react-native-community/netinfo@next
Please report back if this PR is working well for you. If you have any issues, open a new issue with
[v5]
at the start of the issue title.Fixes #201
Fixes #147