leptos-rs / leptos

Build fast web applications with Rust.
https://leptos.dev
MIT License
15.94k stars 627 forks source link

Island props (default / into) #2758

Open VincentBerthier opened 1 month ago

VincentBerthier commented 1 month ago

Describe the bug Tagging island attributes with prop(into) or prop(default) errors.

Leptos Dependencies

0.7.0-beta, or leptos_0.7 branch (commit 25f0186098a01eb40caa846a1524678dc12213e7) I’m told it’s the case in 0.6.x too though.

To Reproduce

  1. activate islands stuff
  2. Write small component:
    #[island]
    pub fn TestIsland(#[prop(default = 10)] value: u32) -> impl IntoView {
    view! { <p>"Value is " {value}</p> }
    }

Expected behavior Should compile…doesn’t.

Screenshots image

VincentBerthier commented 1 day ago

A bit of an update on this: #[prop(into)] seems to work (at least for str -> String or f32 -> f64) #[prop(optional)] val: u32 doesn’t compile (it requires an option), and #[prop(optional)] val: Option<u32>] does compile but gives an hydration warning complaining that it can’t find the wasm function for the component. #[prop(default = 42_u32)] does not compile (trait Deserialize is not implemented for the component)