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

[0.7] view! is unhygienic #3161

Open
jaskij opened this issue Oct 25, 2024 · 1 comment · May be fixed by #3162
Open

[0.7] view! is unhygienic #3161

jaskij opened this issue Oct 25, 2024 · 1 comment · May be fixed by #3162

Comments

@jaskij
Copy link

jaskij commented Oct 25, 2024

Describe the bug

Using 0.7.0-rc0, the view! macro does not compile if leptos::prelude::ElementChild is not in scope.

Leptos Dependencies

leptos = { version = "0.7.0-rc0", default-features = false, features = ["csr"] }

To Reproduce

The code below will not compile without use leptos::prelude::ElementChild on line 3. Adding #[component] does not change the result, so I have removed it to minimize the code.

use leptos::{view, prelude::ClassAttribute, IntoView};
// this is not referenced directly anywhere
use leptos::prelude::ElementChild;

#[allow(non_snake_case)]
pub fn BadView(title: String, body: String) -> impl IntoView {
    view! {
        <div class="content"><hgroup>
            <h1>{title}</h1>
        </hgroup></div>
        <div class="content">{body}</div>
    }
}

Expected behavior
The code should compile.

Screenshots

image

@redforks
Copy link
Contributor

I think it is okay, because view! macro assume of use leptos::prelude::*

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants