yewstack / docs

https://yew.rs
Creative Commons Zero v1.0 Universal
45 stars 46 forks source link

Sample app does not work with web-sys #35

Open thallada opened 4 years ago

thallada commented 4 years ago

I'm talking about the code on this page: https://yew.rs/docs/getting-started/build-a-sample-app

I know the Cargo.toml there says to install yew with the std-web feature, but I thought I could copy the code and it would work in web-sys too. When I tried that I got:

error[E0432]: unresolved import `yew::ClickEvent`
--> src/lib.rs:4:27
  |
4 | use yew::{html, Callback, ClickEvent, Component, ComponentLink, Html, ShouldRender};
  |                           ^^^^^^^^^^ no `ClickEvent` in the root
error[E0282]: type annotations needed
--> src/lib.rs:30:37
   |
30 |             onclick: link.callback(|_| Msg::Click),
   |                                     ^ consider giving this closure parameter a type
error: aborting due to 2 previous errors

I was able to fix it by replacing every reference to ClickEvent with MouseEvent.

I think it would be great to either add a version of the code that works in web-sys on that page or make a separate "Sample app" page for web-sys.

jstarry commented 4 years ago

Agreed, would you be willing to make a PR?