0

I am using build a sample app from yew docs. I don't know why this app throw this error.

enter image description here

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>
jq170727
  • 13,159
  • 3
  • 46
  • 56
Ganesh11
  • 129
  • 1
  • 6

1 Answers1

1

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

Neither 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

  • rename my ~/.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.

jq170727
  • 13,159
  • 3
  • 46
  • 56
  • rename `~/.cargo/registry` to `~/.cargo/registry.bak` works fine. Could you tell me why rename file work? Is it because of file name conflict? – Ganesh11 Jan 31 '23 at 01:45
  • That directory is where `cargo` keeps crates you download (like the corrupted `yew-0.20.0` in this case). Over time it [can get large](https://stackoverflow.com/questions/64063818/why-is-the-cargo-directory-so-big). Renaming the directory makes `cargo` behave as if it's not there. I only suggested renaming it instead of deleting it in case you were experiencing some other problem and/or wanted to keep the corrupted one around for further investigation. Otherwise you can remove it to reclaim space on your system. – jq170727 Jan 31 '23 at 08:35