From 090d1fdb718e12baa3280da2130e30f3709eb248 Mon Sep 17 00:00:00 2001 From: Kaede Hoshikawa Date: Tue, 23 Nov 2021 20:28:36 +0900 Subject: [PATCH] Fix router docs. --- website/docs/concepts/router.md | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/website/docs/concepts/router.md b/website/docs/concepts/router.md index 53d6176b0d9..43bc0f15cbd 100644 --- a/website/docs/concepts/router.md +++ b/website/docs/concepts/router.md @@ -209,7 +209,7 @@ Your components will re-render when provided values change. #### Struct components -In order to react on route changes, you can pass a callback closure to the `listen()` method of `AnyHistory`. +In order to react on route changes, you can pass a callback closure to the `add_history_listener()` method of `ctx.link()`. :::note The history listener will get unregistered once it is dropped. Make sure to store the handle inside your component state. @@ -217,14 +217,13 @@ The history listener will get unregistered once it is dropped. Make sure to stor ```rust ,ignore fn create(ctx: &Context) -> Self { - let _listener = ctx.link() - .history() - .unwrap() - .listen(ctx.link().callback( + let listener = ctx.link() + .add_history_listener(ctx.link().callback( // handle event - )); + )) + .unwrap(); MyComponent { - _listener + _listener: listener } } ```