'online/offline eventListener in cordova inconsistent
I'm on a project which uses react inside cordova.
I've installed cordova-plugin-network-information plugin at the root level (cordova part) and using below inside useEffect but the behaviour of the event listener is very inconsistent within the app.
I tried with window.addEventListener as well but it is not working on the ios simulator. Although, it works if I run the app on the react side directly. (go to react folder and run on the browser)
By very inconsistent -> sometimes it works well (detect online/offline correctly), sometimes it works opposite (detect as offline when online and online when offline), and sometime it doesn't detect at all.
document.addEventListener("online", handleOnLine, false);
document.addEventListener("offline", handleOffLine, false);
I'm not sure what is wrong with the implementation since I've researched about this and everyone seems to be not having an issue but me and my coworkers are having same issues.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
