I am new to Rust and Yew and I need some assistance in applying a useState hook inside an app component in Yew that looks like this:
struct BookList
use gloo_net::http::Request;
use yew::prelude::*;
#[function_component(App)]
pub fn app() -> Html {
let (books: UseStateHandle<Vec<BookList>> = use_state(|| vec![]);
async fn fetch_books() {
let response: Vec<> = Request::get("http://localhost:3000/books");
let cloned_books = books.clone():
cloned_books.set(response.data);
}
html! {
<div>
{"App"}
</div>
}
}
I got the error mismatched types. Where I have the parens, it says it expected a struct UseStateHandle
, found tuple.