diff --git a/leptos_macro/src/component.rs b/leptos_macro/src/component.rs index 3c7b4d060b..b6443faa18 100644 --- a/leptos_macro/src/component.rs +++ b/leptos_macro/src/component.rs @@ -232,6 +232,7 @@ impl ToTokens for Model { quote! {} }; + let body_name = unmodified_fn_name_from_fn_name(&body_name); let body_expr = if *is_island { quote! { ::leptos::SharedContext::with_hydration(move || { @@ -1169,3 +1170,7 @@ pub fn module_name_from_fn_signature(sig: &Signature) -> Ident { let name = format!("component_module_{snake}"); Ident::new(&name, sig.ident.span()) } + +pub fn unmodified_fn_name_from_fn_name(ident: &Ident) -> Ident { + Ident::new(&format!("__{ident}"), ident.span()) +} diff --git a/leptos_macro/src/lib.rs b/leptos_macro/src/lib.rs index a7dd51f296..4267a48804 100644 --- a/leptos_macro/src/lib.rs +++ b/leptos_macro/src/lib.rs @@ -32,7 +32,9 @@ impl Default for Mode { mod params; mod view; -use crate::component::module_name_from_fn_signature; +use crate::component::{ + module_name_from_fn_signature, unmodified_fn_name_from_fn_name, +}; use view::{client_template::render_template, render_view}; mod component; mod server; @@ -610,6 +612,8 @@ pub fn component(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream { span: unexpanded.vis.span(), }) } + unexpanded.sig.ident = + unmodified_fn_name_from_fn_name(&unexpanded.sig.ident); let module_name = module_name_from_fn_signature(&unexpanded.sig); quote! { #expanded @@ -621,7 +625,8 @@ pub fn component(args: proc_macro::TokenStream, s: TokenStream) -> TokenStream { #unexpanded } } - } else if let Ok(dummy) = dummy { + } else if let Ok(mut dummy) = dummy { + dummy.sig.ident = unmodified_fn_name_from_fn_name(&dummy.sig.ident); let module_name = module_name_from_fn_signature(&dummy.sig); quote! { #[doc(hidden)]