DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
19.24k stars 731 forks source link

Shorthand notation breaking rsx! macro with conditional rendering #2362

Open LouisTruch opened 2 months ago

LouisTruch commented 2 months ago

Problem

If you're using conditional rendering in the rsx! macro, the shorthand notation breaks the rsx! macro.

Steps To Reproduce

let class = " ";
let onclick = move |event: MouseEvent| {
};

rsx!(
        div {
            class: if let Some(dark) = light_state.read().is_on() { "{dark}" },
            class,
            onclick,
            Router::<Route> {}
        }
)

This does not compile and make the rsx! macro panics with error: proc macro panicked = help: message: expected an expression. If you use the full notation it works though, but dx fmt with the last version of the CLI will force the swap to the shorthand one.

Expected behavior

Environment:

Questionnaire