leptos-rs / leptos

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

Island props (default / into) #2758

Open VincentBerthier opened 3 months ago

VincentBerthier commented 3 months 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 2 months 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)