react-clear-cache
A component to manage application updates.
Demo
See demo
Install
$ npm install --save react-clear-cache
Add script in package.json
This will generate meta.json
file. This will have the version key with the latest build.
{
"postbuild": "npm run generate-build-meta",
"generate-build-meta": "./node_modules/react-clear-cache/bin/cli.js"
}
Usage
import * as React from 'react';
import ClearCache from 'react-clear-cache';
const App: React.FC<{}> = () => {
return (
<div>
<ClearCache>
{({ loading, latestVersion, isLatestVersion, emptyCacheStorage }) =>
<div>App works!</div>
}
</ClearCache>
</div>
);
};
export default App;
Props
duration
: number
You can set the duration when to fetch for new updates.
Render prop function
loading
: boolean
A boolean that indicates whether the request is in flight
latestVersion
: string
A string containing the latest version number of the build.
isLatestVersion
: boolean
A boolean that indicates if the user has the latest version.
emptyCacheStorage
: () => void
This function empty the CacheStorage and reloads the page.
Contributors
- noahjohn9259
License
MIT © noahjohn9259