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
`useBeforeLeave` takes a function that will be called prior to leaving a route. The function will be called with:
899
900
900
901
- from (_Location_): current location (before change).
901
-
- to (_string | number_}: path passed to `navigate`.
902
-
- options (_NavigateOptions_}: options passed to `navigate`.
903
-
- preventDefault (_void function_): call to block the route change.
904
-
- defaultPrevented (_readonly boolean_): true if any previously called leave handlers called preventDefault().
905
-
- retry (_void function_, _force?: boolean_ ): call to retry the same navigation, perhaps after confirming with the user. Pass `true` to skip running the leave handlers again (ie force navigate without confirming).
902
+
- to (_string | number_): path passed to `navigate`.
903
+
- options (_NavigateOptions_): options passed to `navigate`.
904
+
- preventDefault (_function_): call to block the route change.
905
+
- defaultPrevented (_readonly boolean_): `true` if any previously called leave handlers called `preventDefault`.
906
+
- retry (_function_, _force?: boolean_ ): call to retry the same navigation, perhaps after confirming with the user. Pass `true` to skip running the leave handlers again (i.e. force navigate without confirming).
* `useMatch` takes an accessor that returns the path and creates a `Memo` that returns match information if the current path matches the provided path.
148
+
* Useful for determining if a given path matches the current route.
* useBeforeLeave takes a function that will be called prior to leaving a route.
215
+
* The function will be called with:
216
+
*
217
+
* - from (*Location*): current location (before change).
218
+
* - to (*string | number*): path passed to `navigate`.
219
+
* - options (*NavigateOptions*): options passed to navigate.
220
+
* - preventDefault (*function*): call to block the route change.
221
+
* - defaultPrevented (*readonly boolean*): `true` if any previously called leave handlers called `preventDefault`.
222
+
* - retry (*function*, force?: boolean ): call to retry the same navigation, perhaps after confirming with the user. Pass `true` to skip running the leave handlers again (i.e. force navigate without confirming).
223
+
*
224
+
* @example
225
+
* ```js
226
+
* useBeforeLeave((e: BeforeLeaveEventArgs) => {
227
+
* if (form.isDirty && !e.defaultPrevented) {
228
+
* // preventDefault to block immediately and prompt user async
229
+
* e.preventDefault();
230
+
* setTimeout(() => {
231
+
* if (window.confirm("Discard unsaved changes - are you sure?")) {
232
+
* // user wants to proceed anyway so retry with force=true
0 commit comments