I am using build a sample app from yew docs. I don't know why this app throw this error.
this is yew version in Cargo.toml
[dependencies]
yew = { version = "0.20.0", features = ["csr"] }
this is code in main.rs
use yew::prelude::*;
#[function_component]
fn App() -> Html {
let counter = use_state(|| 0);
let onclick = {
let counter = counter.clone();
move |_| {
let value = *counter + 1;
counter.set(value);
}
};
html! {
<div>
<button {onclick}>{ "+1" }</button>
<p>{ *counter }</p>
</div>
}
}
fn main() {
yew::Renderer::<App>::new().render();
}
this is index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Yew App</title>
</head>
The code in your screenshot doesn't quite match the example you posted here (there's no UseStateHandle, etc) but assuming that's not an issue I took a quick look at
~/.cargo/registry/src/github.com-1ecc6299db9ec823/yew-0.20.0/src/lib.rs
on my system andNeither of those has a pub(crate) fn start_app() -> {
at line 348. They only have 346 lines.
I suspect something's wrong with your cargo registry. You should take a closer look at the files on your system to confirm this.
I don't know if there's a way to correct this but if I were to encounter this condition I would
~/.cargo/registry
to something like ~/.cargo/registry.bak
and then try again.
If that fixed the problem I'd remove the ~/.cargo/registry.bak
. If not I'd put it back.