Skip to content

Commit 85f7bb2

Browse files
committed
fix for reloading
1 parent 6e39c89 commit 85f7bb2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/App.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,17 +161,19 @@ export default function App() {
161161

162162
function update() {
163163
updateServiceWorker(true)
164+
// Trigger page reload
165+
window.location.reload()
164166
}
165167

166168
useEffect(() => {
167169
if (window.isSecureContext && navigator.serviceWorker) {
168-
// check for sw updates on page change
169-
navigator.serviceWorker.getRegistrations().then((regs) => regs.forEach((reg) => reg.update()))
170-
if (!needRefresh) {
171-
return
170+
// check for sw updates on page change
171+
navigator.serviceWorker.getRegistrations().then((regs) => regs.forEach((reg) => reg.update()))
172+
if (!needRefresh) {
173+
return
174+
}
175+
update()
172176
}
173-
update()
174-
}
175177
}, [location])
176178

177179
function onUpdate() {

0 commit comments

Comments
 (0)