Detect components called as functions (#2461)
* detect components called as functions * use the existing component name information instead of a thread local
This commit is contained in:
1 parent
7efe4d0e49
commit
5024139e01
3 files changed
+38
No files matched your search
@@ -84,6 +84,7 @@ impl ComponentBody {
|
||||
} = sig;
|
||||
let Generics { where_clause, .. } = generics;
|
||||
let (_, ty_generics, _) = generics.split_for_impl();
|
||||
let generics_turbofish = ty_generics.as_turbofish();
|
||||
|
||||
// We generate a struct with the same name as the component but called `Props`
|
||||
let struct_ident = Ident::new(&format!("{fn_ident}Props"), fn_ident.span());
|
||||
@@ -108,6 +109,9 @@ impl ComponentBody {
|
||||
#(#attrs)*
|
||||
#(#props_docs)*
|
||||
#asyncness #vis fn #fn_ident #generics (#props_ident) #fn_output #where_clause {
|
||||
// In debug mode we can detect if the user is calling the component like a function
|
||||
dioxus_core::internal::verify_component_called_as_component(#fn_ident #generics_turbofish);
|
||||
|
||||
#expanded_struct
|
||||
#block
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user