@jswork/react-sw-update-tips
v1.0.0
Published
Update tips for service-worker.
Downloads
23
Readme
react-sw-update-tips
Update tips for service-worker.
installation
npm install -S @jswork/react-sw-update-tips
update
npm update @jswork/react-sw-update-tips
properties
| Name | Type | Required | Default | Description | | --------- | ------ | -------- | ---------------------------- | ------------------------------------- | | className | string | false | - | The extended className for component. | | text | union | false | '↺ 有新版本更新啦,点击刷新' | Tips text. | | value | bool | false | false | Default value. | | hidden | bool | false | false | The html hidden status. | | onChange | func | false | - | The change handler. |
usage
- import css
@import "~@jswork/react-sw-update-tips/dist/style.scss";
// customize your styles:
$react-sw-update-tips-options: ()
- import js
import NxOfflineSw from '@jswork/next-offline-sw';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactSwUpdateTips from '@jswork/react-sw-update-tips';
import './assets/style.scss';
class App extends React.Component {
state = {
hasUpdate: true
};
componentDidMount() {
this.installSw();
}
installSw() {
NxOfflineSw.install({
onUpdateReady: function () {
// this.setState({ hasUpdate: false });
console.log('SW Event:', 'onUpdateReady');
}
});
}
render() {
return (
<div className="app-container">
<ReactSwUpdateTips value={this.state.hasUpdate} />
</div>
);
}
}
ReactDOM.render(<App />, document.getElementById('app'));
documentation
- https://afeiship.github.io/react-sw-update-tips/
license
Code released under the MIT license.