This file contains hidden or 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
import { useEffect, useRef } from 'react'; | |
const SERVICE_WORKER_UPDATE_CHECK_INTERVAL = 5 * 60 * 1000; // every 5 minutes | |
/** | |
* A hook to enable a periodic update checker for new service workers. | |
* | |
* For example, when new build is deployed, a new service worker is generated. | |
* However, when user navigates to the web page old Service Worker is still in control, | |
* which will return an old build from its cache. |