From 77b08f2330ebf6ad750adbcfd9f28967509765d4 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Wed, 19 Jun 2024 08:54:39 -0700 Subject: [PATCH] fix router resource docs --- examples/router_resource.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/examples/router_resource.rs b/examples/router_resource.rs index 57a7f90dc..52cd7dd2e 100644 --- a/examples/router_resource.rs +++ b/examples/router_resource.rs @@ -25,16 +25,15 @@ fn App() -> Element { } } +// We use id: ReadOnlySignal instead of id: i32 to make id work with reactive hooks +// Any i32 we pass in will automatically be converted into a ReadOnlySignal #[component] fn Blog(id: ReadOnlySignal) -> Element { async fn future(n: i32) -> i32 { n } - // if you use the naive approach, the "Blog post {id}" below will never update when clicking links! - // let res = use_resource(move || future(id)); - - // the use_reactive hook is required to properly update when clicking links to this component, from this component + // Because we accept ReadOnlySignal instead of i32, the resource will automatically subscribe to the id when we read it let res = use_resource(move || future(id())); match res() {