feat: make component name accessible

This commit is contained in:
Jonathan Kelley committed 2022-01-31 02:49:37 -05:00
1 parent 4ae11b5756
commit 0820e18d3d
2 files changed
+6

No files matched your search

+3
View File
@@ -135,11 +135,14 @@ impl ToTokens for Component {
None => quote! { None }, None => quote! { None },
}; };
let fn_name = self.name.segments.last().unwrap().ident.to_string();
tokens.append_all(quote! { tokens.append_all(quote! {
__cx.component( __cx.component(
#name, #name,
#builder, #builder,
#key_token, #key_token,
#fn_name
) )
}) })
} }
+3
View File
@@ -385,6 +385,7 @@ pub struct VComponent<'src> {
pub scope: Cell<Option<ScopeId>>, pub scope: Cell<Option<ScopeId>>,
pub can_memoize: bool, pub can_memoize: bool,
pub user_fc: *const (), pub user_fc: *const (),
pub fn_name: &'static str,
pub props: RefCell<Option<Box<dyn AnyProps + 'src>>>, pub props: RefCell<Option<Box<dyn AnyProps + 'src>>>,
} }
@@ -549,6 +550,7 @@ impl<'a> NodeFactory<'a> {
component: fn(Scope<'a, P>) -> Element, component: fn(Scope<'a, P>) -> Element,
props: P, props: P,
key: Option<Arguments>, key: Option<Arguments>,
fn_name: &'static str,
) -> VNode<'a> ) -> VNode<'a>
where where
P: Properties + 'a, P: Properties + 'a,
@@ -559,6 +561,7 @@ impl<'a> NodeFactory<'a> {
can_memoize: P::IS_STATIC, can_memoize: P::IS_STATIC,
user_fc: component as *const (), user_fc: component as *const (),
originator: self.scope.scope_id(), originator: self.scope.scope_id(),
fn_name,
props: RefCell::new(Some(Box::new(VComponentProps { props: RefCell::new(Some(Box::new(VComponentProps {
// local_props: RefCell::new(Some(props)), // local_props: RefCell::new(Some(props)),
// heap_props: RefCell::new(None), // heap_props: RefCell::new(None),