DioxusLabs / dioxus

Fullstack GUI library for web, desktop, mobile, and more.

Home Page:https://dioxuslabs.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Shorthand notation breaking rsx! macro with conditional rendering

LouisTruch opened this issue · comments

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

  • For the macro not to panic ?
  • For dx fmt not to force the shorthand notation maybe, or as an option in the command and/or dioxus.toml ?

Environment:

  • Dioxus version: 0.5.x, rev is c9ab09b
  • Latest version of the CLI from git

Questionnaire

  • I don't have time to fix this right now, but maybe later