I would like to check my Internet connection in my Ionic React application. All what I find on Internet is for Ionic angular. How can I do that ?
Asked
Active
Viewed 1,108 times
2 Answers
0
Ok thanks, I find something else ...
['load', 'online', 'offline'].forEach(function (e) {
window.addEventListener(e, () => { props.setNetworkState(navigator.onLine ? "online" : "offline") });
});

Timothy Cuenat
- 16
- 5
-
Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 06 '21 at 06:41
-
Are you tested it in a real device? window.navigator.onLine works only on the browser but if you target a real device (Android...) it doesn't work. – Abdes Oct 08 '21 at 11:47