Skip to content

Commit 4bdd6b4

Browse files
authored
Add setTimeout back to unstable_usePrompt (#10718)
1 parent 9749566 commit 4bdd6b4

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"react-router-dom": patch
3+
---
4+
5+
[Remove] add back in `setTimeout` removal from `usePrompt`

packages/react-router-dom/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1465,7 +1465,10 @@ function usePrompt({ when, message }: { when: boolean; message: string }) {
14651465
if (blocker.state === "blocked") {
14661466
let proceed = window.confirm(message);
14671467
if (proceed) {
1468-
blocker.proceed();
1468+
// This timeout is needed to avoid a weird "race" on POP navigations
1469+
// between the `window.history` revert navigation and the result of
1470+
// `window.confirm`
1471+
setTimeout(blocker.proceed, 0);
14691472
} else {
14701473
blocker.reset();
14711474
}

0 commit comments

Comments
 (0)