react-offline-cache
Create a cache to offline connection
A basic cache for React applications. Offline cache to applications. It also serves as a reference for more advanced caching implementations.
Install ![](https://github.com/natancabral/react-offline-cache/blob/main/images/npm-tile.png)
npm install react-offline-cache
src/index.js
import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
import * as roc from 'react-offline-cache';
ReactDOM.render(<App />, document.getElementById("root"));
roc.register();
How to remove
roc.unregister();
Is online
console.log('online:', roc.isOnline());
Is offline
if(roc.isOffline()) {
window.alert('Your internet is offline. Sorry.');
}
License
The MIT License.
Author
Thank you