Check out example codes for "no internet connection html page". It will help you in understanding the concepts better.

Code Example 1

if (navigator.onLine) {
  console.log("You are online");
} else {
  console.log("You are offline");
}

Code Example 2

window.addEventListener("online", function() {
  alert("You are online now!");
});

window.addEventListener("offline", function() {
  alert("Oops! You are offline now!");
});

Learn ReactJs, React Native from akashmittal.com