yewstack / yew

Rust / Wasm framework for creating reliable and efficient web applications

Home Page:https://yew.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yew-router example does not compile

AndreasBergmeier6176 opened this issue · comments

This is about:

  • A typo
  • Innaccurate/misleading documentation (e.g. technically incorrect advice)
  • Undocumented code
  • 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.

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

[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"

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

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.

Would you like to PR a change for 0.21 docs?