Skip to content

Commit 6d94196

Browse files
authored
Add state/info when redirecting
Closes #286.
1 parent efc82e6 commit 6d94196

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,14 +708,15 @@ Because precommit handlers can be used to cancel the navigation before the URL u
708708
709709
#### Redirects during deferred commit
710710
711-
The `precommitHandler` callback accepts an argument, which is a `controller` that can perform certain actions on the precommitted navigation, in particular redirecting. This updates the eventual destination of the `"push"` or `"replace"` navigation. An example usage is as follows
711+
The `precommitHandler` callback accepts an argument, which is a `controller` that can perform certain actions on the precommitted navigation, in particular redirecting. This updates the eventual destination, and potentially the state/info, of the `"push"` or `"replace"` navigation.
712+
An example usage is as follows:
712713
713714
```js
714715
navigation.addEventListener("navigate", e => {
715716
e.intercept({
716717
async precommitHandler(controller) {
717718
if (await isLoginGuarded(e.destination)) {
718-
controller.redirect("/login");
719+
controller.redirect("/login", {state: "login-redirect", info: "some-info"});
719720
}
720721
}
721722

0 commit comments

Comments
 (0)