@feizheng/react-sw-update-tips

1.0.4 • Public • Published

react-sw-update-tips

Update tips for service-worker.

version license size download

installation

npm install -S @feizheng/react-sw-update-tips

update

npm update @feizheng/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

  1. import css
@import "~@feizheng/react-sw-update-tips/dist/style.scss";

// customize your styles:
$react-sw-update-tips-options: ()
  1. import js
import NxOfflineSw from '@feizheng/next-offline-sw';
import React from 'react';
import ReactDOM from 'react-dom';
import ReactSwUpdateTips from '@feizheng/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

license

Code released under the MIT license.

/@feizheng/react-sw-update-tips/

    Package Sidebar

    Install

    npm i @feizheng/react-sw-update-tips

    Weekly Downloads

    6

    Version

    1.0.4

    License

    MIT

    Unpacked Size

    21 kB

    Total Files

    6

    Last publish

    Collaborators

    • afeiship