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

Shorthand notation breaking rsx! macro with conditional rendering #2362

Open
1 task done
LouisTruch opened this issue Apr 24, 2024 · 0 comments
Open
1 task done

Shorthand notation breaking rsx! macro with conditional rendering #2362

LouisTruch opened this issue Apr 24, 2024 · 0 comments
Labels
autoformatting Related to the autofmt crate bug Something isn't working

Comments

@LouisTruch
Copy link

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
@ealmloff ealmloff added bug Something isn't working autoformatting Related to the autofmt crate labels Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autoformatting Related to the autofmt crate bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants