We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I am currently unable to use the library with service worker functionality because it is breaking my service worker update prompts (https://github.com/vite-pwa/vite-plugin-pwa/blob/main/docs/frameworks/react.md#prompt-for-update). I think using service_worker_register might be the solution. Still, I'm unsure how to implement it.
This is my current working SW.tsx:
import Button from '@mui/material/Button'; import { useCallback, useEffect, useRef } from 'react'; import { useRegisterSW } from 'virtual:pwa-register/react'; import type { SnackbarKey } from 'notistack'; import useNotifications from '@/store/notifications'; function SW() { const [, notificationsActions] = useNotifications(); const notificationKey = useRef<SnackbarKey | null>(null); const { offlineReady: [offlineReady, setOfflineReady], needRefresh: [needRefresh, setNeedRefresh], updateServiceWorker, } = useRegisterSW(); const close = useCallback(() => { setOfflineReady(false); setNeedRefresh(false); if (notificationKey.current !== null && notificationKey.current !== undefined) { notificationsActions.close(notificationKey.current); } }, [setOfflineReady, setNeedRefresh, notificationsActions]); useEffect(() => { if (offlineReady) { notificationsActions.push({ options: { autoHideDuration: 4500, content: <Alert severity="success">App is ready to work offline.</Alert>, }, }); } else if (needRefresh) { notificationKey.current = notificationsActions.push({ message: 'New content is available, click on reload button to update.', options: { variant: 'warning', persist: true, action: ( <> <Button onClick={async () => updateServiceWorker()}>Reload</Button> <Button onClick={close}>Close</Button> </> ), }, }); } }, [close, needRefresh, offlineReady, notificationsActions, updateServiceWorker]); return null; } export default SW;
The text was updated successfully, but these errors were encountered:
@esomore, did you get any resolution to this, I'm currently running into the same issue.
Sorry, something went wrong.
Not yet :(
No branches or pull requests
I am currently unable to use the library with service worker functionality because it is breaking my service worker update prompts (https://github.com/vite-pwa/vite-plugin-pwa/blob/main/docs/frameworks/react.md#prompt-for-update). I think using service_worker_register might be the solution. Still, I'm unsure how to implement it.
This is my current working SW.tsx:
The text was updated successfully, but these errors were encountered: