You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Could you consider adding the previous state as a property to useBlocker?
Here’s a use case:
constblocker=useBlocker(isDirty);constpreviousBlockerState=useRef(blocker.state);useEffect(()=>{if(previousBlockerState.current!=="blocked")reset(selectedRow);},[previousBlockerState.current,selectedRow,reset]);consthandleBlocker=useCallback(async(actionType,onConfirm,onCancel)=>{constconfirmed=awaitdialogs.confirm(`You have unsaved changes. Are you sure you want to ${actionType} without saving them? This action cannot be undone.`,{okText: "Confirm",severity: "warning"},);if(confirmed)onConfirm();elseonCancel();},[dialogs],);
Currently, I’m using a workaround with a ref to store the blocker.state in order to prevent resetting the form when the blocker is triggered. It would be more efficient - less boilerplate code - if this previous state could be managed directly within useBlocker, avoiding the need for boilerplate code like the ref.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Could you consider adding the previous state as a property to
useBlocker
?Here’s a use case:
Currently, I’m using a workaround with a
ref
to store theblocker.state
in order to prevent resetting the form when the blocker is triggered. It would be more efficient - less boilerplate code - if thisprevious state
could be managed directly withinuseBlocker
, avoiding the need for boilerplate code like theref
.Beta Was this translation helpful? Give feedback.
All reactions