This is about:
Problem
This is an excerpt from the tutorial, after tellinng new users to add wasm-bindgen-futures into the Cargo.toml, the problem is it should instead use yew_platform::spawn_local and use_future:
#[component]
fn App() -> Html {
let videos = use_state(|| vec![]);
{
let videos = videos.clone();
use_effect_with((), move |_| {
let videos = videos.clone();
wasm_bindgen_futures::spawn_local(async move {
let fetched_videos: Vec<Video> = Request::get("https://yew.rs/tutorial/data.json")
.send()
.await
.unwrap()
.json()
.await
.unwrap();
videos.set(fetched_videos);
});
|| ()
});
}
// ...
html! {
<>
<h1>{ "RustConf Explorer" }</h1>
<div>
<h3>{ "Videos to watch" }</h3>
<VideosList videos={(*videos).clone()} on_click={on_video_select} />
</div>
// ...
</>
}
}
Details about the solution you'd like (Optional)
Use up to date Yew API
Questionaire (Optional)
This is about:
Problem
This is an excerpt from the tutorial, after tellinng new users to add
wasm-bindgen-futuresinto the Cargo.toml, the problem is it should instead useyew_platform::spawn_localanduse_future:Details about the solution you'd like (Optional)
Use up to date Yew API
Questionaire (Optional)