fix router resource docs
This commit is contained in:
1 parent
b6dc2a2230
commit
77b08f2330
1 file changed
+3
-4
@@ -25,16 +25,15 @@ fn App() -> Element {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We use id: ReadOnlySignal<i32> instead of id: i32 to make id work with reactive hooks
|
||||||
|
// Any i32 we pass in will automatically be converted into a ReadOnlySignal<i32>
|
||||||
#[component]
|
#[component]
|
||||||
fn Blog(id: ReadOnlySignal<i32>) -> Element {
|
fn Blog(id: ReadOnlySignal<i32>) -> Element {
|
||||||
async fn future(n: i32) -> i32 {
|
async fn future(n: i32) -> i32 {
|
||||||
n
|
n
|
||||||
}
|
}
|
||||||
|
|
||||||
// if you use the naive approach, the "Blog post {id}" below will never update when clicking links!
|
// Because we accept ReadOnlySignal<i32> instead of i32, the resource will automatically subscribe to the id when we read it
|
||||||
// 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
|
|
||||||
let res = use_resource(move || future(id()));
|
let res = use_resource(move || future(id()));
|
||||||
|
|
||||||
match res() {
|
match res() {
|
||||||
|
|||||||
Reference in new issue
Block a user