natancabral / react-offline-cache

A basic cache for React applications. Offline cache to applications. It also serves as a reference for more advanced caching implementations.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

npm install react-offline-cache

src/index.js

import React from "react";
import ReactDOM from "react-dom";
import App from "./App";
// react-offline-cache
import * as roc from 'react-offline-cache';

ReactDOM.render(<App />, document.getElementById("root"));

// init faster
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

Natan Cabral
natancabral@hotmail.com
https://github.com/natancabral/

Thank you

About

A basic cache for React applications. Offline cache to applications. It also serves as a reference for more advanced caching implementations.


Languages

Language:JavaScript 100.0%