Skip to content

Commit

Permalink
Add setTimeout back to unstable_usePrompt (#10718)
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 authored Jul 19, 2023
1 parent 9749566 commit 4bdd6b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/prompt-add-back-settimeout.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-router-dom": patch
---

[Remove] add back in `setTimeout` removal from `usePrompt`
5 changes: 4 additions & 1 deletion packages/react-router-dom/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1465,7 +1465,10 @@ function usePrompt({ when, message }: { when: boolean; message: string }) {
if (blocker.state === "blocked") {
let proceed = window.confirm(message);
if (proceed) {
blocker.proceed();
// This timeout is needed to avoid a weird "race" on POP navigations
// between the `window.history` revert navigation and the result of
// `window.confirm`
setTimeout(blocker.proceed, 0);
} else {
blocker.reset();
}
Expand Down

0 comments on commit 4bdd6b4

Please sign in to comment.