feat: make component name accessible

This commit is contained in:
Jonathan Kelley 2022-01-31 02:49:37 -05:00
parent 4ae11b5756
commit 0820e18d3d
2 changed files with 6 additions and 0 deletions

View file

@ -135,11 +135,14 @@ impl ToTokens for Component {
None => quote! { None },
};
let fn_name = self.name.segments.last().unwrap().ident.to_string();
tokens.append_all(quote! {
__cx.component(
#name,
#builder,
#key_token,
#fn_name
)
})
}

View file

@ -385,6 +385,7 @@ pub struct VComponent<'src> {
pub scope: Cell<Option<ScopeId>>,
pub can_memoize: bool,
pub user_fc: *const (),
pub fn_name: &'static str,
pub props: RefCell<Option<Box<dyn AnyProps + 'src>>>,
}
@ -549,6 +550,7 @@ impl<'a> NodeFactory<'a> {
component: fn(Scope<'a, P>) -> Element,
props: P,
key: Option<Arguments>,
fn_name: &'static str,
) -> VNode<'a>
where
P: Properties + 'a,
@ -559,6 +561,7 @@ impl<'a> NodeFactory<'a> {
can_memoize: P::IS_STATIC,
user_fc: component as *const (),
originator: self.scope.scope_id(),
fn_name,
props: RefCell::new(Some(Box::new(VComponentProps {
// local_props: RefCell::new(Some(props)),
// heap_props: RefCell::new(None),