Created
March 8, 2018 01:38
-
-
Save nirzaq/b91fdf3e468bc6c67d1ed1701a185f66 to your computer and use it in GitHub Desktop.
componentDidMount Next.js SWprecache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
componentDidMount() { | |
if ("serviceWorker" in navigator) { | |
navigator.serviceWorker | |
.register("/service-worker.js") | |
.then(registration => { | |
console.log("service worker registration successful"); | |
}) | |
.catch(err => { | |
console.warn("service worker registration failed", err.message); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment