DioxusLabs/dioxus · error · syn::Error

Props is not supported for unit structs

Error message

Props is not supported for unit structs

What it means

The `#[derive(Props)]` macro rejects unit structs at derive expansion time, emitting this compile error at the struct's span. Props require named fields to map attribute arguments; a unit struct has no fields to accept any props, so deriving Props on one is a compile error.

Solutions

  1. Add named fields to the props struct or remove the Props derive; unit structs cannot derive Props.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at packages/core-macro/src/props/mod.rs:59 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/249ff02676aef0db. Report an issue: GitHub.

Appendix: source

Thrown at packages/core-macro/src/props/mod.rs:59

                let build_method = struct_info.build_method_impl();

                quote! {
                    #builder_creation
                    #conversion_helper
                    #( #fields )*
                    #( #extends )*
                    #( #required_fields )*
                    #build_method
                }
            }
            syn::Fields::Unnamed(_) => {
                return Err(Error::new(
                    ast.span(),
                    "Props is not supported for tuple structs",
                ));
            }
            syn::Fields::Unit => {
                return Err(Error::new(
                    ast.span(),
                    "Props is not supported for unit structs",
                ));
            }
        },
        syn::Data::Enum(_) => {
            return Err(Error::new(ast.span(), "Props is not supported for enums"));
        }
        syn::Data::Union(_) => {
            return Err(Error::new(ast.span(), "Props is not supported for unions"));
        }
    };
    Ok(data)
}

mod util {
    use quote::ToTokens;

View on GitHub (pinned to 24f6a829df)