mirror of
https://github.com/nowcommunity/nowdatabase.git
synced 2026-10-12 19:13:52 +03:00
fix: Fix invalid blocker state transition in UnsavedChangesProvider
Fix #1184: Time Unit error caused by invalid blocker state transition. The error 'Invalid blocker state transition: unblocked -> proceeding' occurred when calling blocker.proceed() in UnsavedChangesProvider. Root cause: setDirty(false) was called before blocker.proceed?.(), which triggered a re-render that could change the blocker state before proceed was called. This caused React Router's internal state machine to receive a proceed call when the blocker was no longer in the 'blocked' state. Fix: - Call blocker.proceed?.() before setDirty(false) in handleConfirm - Add additional state check in isSamePathNavigation useEffect to ensure blocker is still 'blocked' before calling proceed() Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
This commit is contained in:
@@ -72,8 +72,8 @@ export const UnsavedChangesProvider = ({
|
||||
|
||||
const handleConfirm = useCallback(() => {
|
||||
if (blocker.state === 'blocked') {
|
||||
setDirty(false)
|
||||
blocker.proceed?.()
|
||||
setDirty(false)
|
||||
}
|
||||
}, [blocker, setDirty])
|
||||
|
||||
@@ -91,7 +91,7 @@ export const UnsavedChangesProvider = ({
|
||||
|
||||
useEffect(() => {
|
||||
const proceed = blocker.proceed as (() => void) | undefined
|
||||
if (isSamePathNavigation && proceed) {
|
||||
if (isSamePathNavigation && proceed && blocker.state === 'blocked') {
|
||||
proceed()
|
||||
}
|
||||
}, [blocker, isSamePathNavigation])
|
||||
|
||||
Reference in New Issue
Block a user