DioxusLabs/dioxus · error · syn::Error

Must return a <dioxus_core::Element>

Error message

Must return a <dioxus_core::Element>

What it means

Error "Must return a <dioxus_core::Element>" thrown in DioxusLabs/dioxus.

Source

Thrown at packages/core-macro/src/component.rs:461

                return None;
            }

            let res = crate::utils::DeprecatedAttribute::from_meta(&attr.meta);

            match res {
                Err(e) => panic!("{}", e.to_string()),
                Ok(v) => Some(v),
            }
        }),
        input_arg_doc: arg_doc,
    })
}

fn validate_component_fn(item_fn: &ItemFn) -> Result<()> {
    // Do some validation....
    // 1. Ensure the component returns *something*
    if item_fn.sig.output == ReturnType::Default {
        return Err(Error::new(
            item_fn.sig.output.span(),
            "Must return a <dioxus_core::Element>".to_string(),
        ));
    }

    // 2. make sure there's no lifetimes on the component - we don't know how to handle those
    if item_fn.sig.generics.lifetimes().count() > 0 {
        return Err(Error::new(
            item_fn.sig.generics.span(),
            "Lifetimes are not supported in components".to_string(),
        ));
    }

    // 3. we can't handle async components
    if item_fn.sig.asyncness.is_some() {
        return Err(Error::new(
            item_fn.sig.asyncness.span(),
            "Async components are not supported".to_string(),

View on GitHub (pinned to 393d190a80)

When it happens

Trigger: Thrown at packages/core-macro/src/component.rs:461 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of DioxusLabs/dioxus@393d190a80 (2026-08-16). Data as JSON: /api/errors/1bb26acb7e62b90b. Report an issue: GitHub.