yew icon indicating copy to clipboard operation
yew copied to clipboard

yew-router example does not compile

Open AndreasBergmeier6176 opened this issue 2 years ago • 5 comments

This is about:

  • [ ] A typo
  • [x] Innaccurate/misleading documentation (e.g. technically incorrect advice)
  • [ ] Undocumented code
  • [x] Outdated documentation
  • [ ] Other

Problem

When copying https://yew.rs/docs/next/concepts/router into an editor, I get:

the trait bound `yew_router::Switch<Route>: yew::Component` is not satisfied
the trait `yew::Component` is implemented for `ContextProvider<T>`
required for `yew_router::Switch<Route>` to implement `yew::BaseComponent`

I use latest version of all packages.

Maybe it would be good to either always compile the example code as part of a release or be more specific with which versions that example code used to work.

AndreasBergmeier6176 avatar Nov 30 '23 17:11 AndreasBergmeier6176

Your versions are incorrect. All the examples are tested as part of CI run on every commit. Please show your Cargo.toml file

ranile avatar Nov 30 '23 17:11 ranile

[package]
name = "foo"
version = "0.1.0"
edition = "2021"
description = "Template for starting a Yew project using Trunk"
readme = "README.md"
repository = "https://github.com/yewstack/yew-trunk-minimal-template"
license = "MIT OR Apache-2.0"
keywords = ["yew", "trunk"]
categories = ["gui", "wasm", "web-programming"]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
serde_json = "1.0.108"
yew = { version="0.21", features=["csr"] }
yew-router = { git = "https://github.com/yewstack/yew.git" }

What does seem to work though is using:

yew-router = "0.18.0"

abergmeier avatar Dec 01 '23 20:12 abergmeier

You can't have mismatched versions. Either use both versions from crates.io or git. Yew from git is a different crate compared to 0.21 from crates.io and vice versa. yew-router from git depends on yew from git, so you can't have yew from crates.io there.

This is nothing that yew can do anything about. This is how Rust dependencies work

ranile avatar Dec 01 '23 21:12 ranile

Note however, that https://yew.rs/docs/concepts/router indicates to simply add the git variant - which seems to be the wrong thing to do for most users IMO.

abergmeier avatar Dec 01 '23 22:12 abergmeier

Would you like to PR a change for 0.21 docs?

ranile avatar Dec 01 '23 22:12 ranile