Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

props of type Option<T> cannot use None #3747

Open
arcollector opened this issue Oct 11, 2024 · 1 comment
Open

props of type Option<T> cannot use None #3747

arcollector opened this issue Oct 11, 2024 · 1 comment
Labels

Comments

@arcollector
Copy link

Problem

Hello there, I have this simple code

#[derive(Properties, PartialEq)]
pub struct Props {
    pub id_patient: Option<String>,
    pub id_report: Option<String>,
}

#[function_component(PatientsNavBar)]
pub fn patients_nav_bar(
    Props {
        id_patient,
        id_report,
    }: &Props,
) -> Html {
 html! { /* */ }
}

#[function_component(App)]
fn app() -> Html {
  html! {
     <PatientsNavBar id_patient={None} id_report={None} />
  }
}

the compiler outputs the following the error

type annotations needed
multiple `impl`s satisfying `std::option::Option<_>: IntoPropValue<std::option::Option<std::string::String>>` found in the `yew` crate:
- impl IntoPropValue<std::option::Option<std::string::String>> for std::option::Option<&'static str>;
- impl<T> IntoPropValue<T> for T

Could anybody bring me some light on this matter, how to set an optional prop ?

Environment:

  • Yew version: [ master]
  • Rust version: [1.81.1]
  • Target [wasm32-unknown-unknown]
  • Build tool [trunk]
@iemafzalhassan
Copy link

Hi 👋

can you please assign me this issue? I would like to work on it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants