DioxusLabs/dioxus · error · syn::Error
Receiver parameters are not supported
Error message
Receiver parameters are not supported
What it means
Validation 5 in validate_component_fn: the #[component] fn takes a self/receiver parameter (FnArg::Receiver). Components must be free functions whose arguments are all named props; the faulting input is the method-style declaration.
Solutions
- Remove the `self` receiver from the component; define it as a free function `fn MyComponent(props: MyProps) -> Element` instead of a method.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at packages/core-macro/src/component.rs:498 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of DioxusLabs/dioxus@24f6a829df (2026-08-23).
Data as JSON: /api/errors/35dd74b2022847cf.
Report an issue: GitHub.
Appendix: source
Thrown at packages/core-macro/src/component.rs:498
));
}
// 4. we can't handle const components
if item_fn.sig.constness.is_some() {
return Err(Error::new(
item_fn.sig.constness.span(),
"Const components are not supported".to_string(),
));
}
// 5. no receiver parameters
if item_fn
.sig
.inputs
.iter()
.any(|f| matches!(f, FnArg::Receiver(_)))
{
return Err(Error::new(
item_fn.sig.inputs.span(),
"Receiver parameters are not supported".to_string(),
));
}
Ok(())
}
/// Convert a function arg with a given visibility (provided by the function) and then generate a field for the
/// associated props struct.
fn make_prop_struct_field(f: &FnArg, vis: &Visibility) -> TokenStream {
// There's no receivers (&self) allowed in the component body
let FnArg::Typed(pt) = f else { unreachable!() };
let arg_pat = match pt.pat.as_ref() {
// rip off mutability
// todo: we actually don't want any of the extra bits of the field pattern
Pat::Ident(f) => {View on GitHub (pinned to 24f6a829df)