I have a react component that does this once it is mounted:
const internetConnectivity = navigator.onLine;
This is how I tested it - I mount the component while having wi-fi, then I go back, turn off my wi-fi and mount the component again. The functionality works fine on Chrome and Firefox because internetConnectivity is true when the wi-fi is turned on, and false when it is off.
Unfortunately, on Edge and Opera internetConnectivity is true even after I've turned off the wi-fi. I checked that navigaor.onLine is supported by all 4 browsers, so something else is up with it.