{"record":{"id":"1bb26acb7e62b90b","repo":"DioxusLabs/dioxus","slug":"must-return-a-dioxus-core-element","errorCode":null,"errorMessage":"Must return a <dioxus_core::Element>","messagePattern":"Must return a <dioxus_core::Element>","errorType":"validation","errorClass":"syn::Error","httpStatus":null,"severity":"error","filePath":"packages/core-macro/src/component.rs","lineNumber":461,"sourceCode":"                return None;\n            }\n\n            let res = crate::utils::DeprecatedAttribute::from_meta(&attr.meta);\n\n            match res {\n                Err(e) => panic!(\"{}\", e.to_string()),\n                Ok(v) => Some(v),\n            }\n        }),\n        input_arg_doc: arg_doc,\n    })\n}\n\nfn validate_component_fn(item_fn: &ItemFn) -> Result<()> {\n    // Do some validation....\n    // 1. Ensure the component returns *something*\n    if item_fn.sig.output == ReturnType::Default {\n        return Err(Error::new(\n            item_fn.sig.output.span(),\n            \"Must return a <dioxus_core::Element>\".to_string(),\n        ));\n    }\n\n    // 2. make sure there's no lifetimes on the component - we don't know how to handle those\n    if item_fn.sig.generics.lifetimes().count() > 0 {\n        return Err(Error::new(\n            item_fn.sig.generics.span(),\n            \"Lifetimes are not supported in components\".to_string(),\n        ));\n    }\n\n    // 3. we can't handle async components\n    if item_fn.sig.asyncness.is_some() {\n        return Err(Error::new(\n            item_fn.sig.asyncness.span(),\n            \"Async components are not supported\".to_string(),","sourceCodeStart":443,"sourceCodeEnd":479,"githubUrl":"https://github.com/DioxusLabs/dioxus/blob/24f6a829df0dfa203961a98ea4cae21c2ff27e28/packages/core-macro/src/component.rs#L443-L479","documentation":"Validation 1 in validate_component_fn for #[component]: the function's signature has no return type (ReturnType::Default), i.e. it returns (). Components must evaluate to an Element (Option<VNode>) so they can be rendered; the faulting input is the component fn lacking a -> Element return.","triggerScenarios":"Thrown at packages/core-macro/src/component.rs:461 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Return dioxus_core::Element from the component, typically rsx! { ... }."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"24f6a829df0dfa203961a98ea4cae21c2ff27e28","analyzedAt":"2026-08-23T07:10:14.078Z","contentChangedAt":"2026-08-23T07:10:14.078Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}