diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index 40d9c1b7a..cbe0011b3 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -9,6 +9,7 @@ use crate::{ }; use crate::{Properties, VirtualDom}; use core::panic; +use std::ops::Deref; use std::rc::Rc; use std::vec; use std::{ @@ -16,7 +17,6 @@ use std::{ cell::Cell, fmt::{Arguments, Debug}, }; -use std::{ffi::c_void, ops::Deref}; pub type TemplateId = &'static str; @@ -513,7 +513,7 @@ pub struct VComponent { /// The function pointer of the component, known at compile time /// /// It is possible that components get folded at compile time, so these shouldn't be really used as a key - pub(crate) render_fn: *const c_void, + pub(crate) render_fn: TypeId, pub(crate) props: BoxedAnyProps, } @@ -542,8 +542,9 @@ impl VComponent { // The properties must be valid until the next bump frame P: Properties + 'static, { - let component = Rc::new(component).as_component(); - let render_fn = component.as_ref() as *const _ as *const c_void; + let component = Rc::new(component); + let render_fn = component.id(); + let component = component.as_component(); let vcomp = VProps::new(component,
::memoize, props, fn_name);
VComponent {
diff --git a/packages/core/src/properties.rs b/packages/core/src/properties.rs
index e0ad12f7b..4cb66e10e 100644
--- a/packages/core/src/properties.rs
+++ b/packages/core/src/properties.rs
@@ -1,4 +1,4 @@
-use std::rc::Rc;
+use std::{any::TypeId, rc::Rc};
use crate::innerlude::*;
@@ -62,23 +62,25 @@ where
}
/// Any component that implements the `ComponentFn` trait can be used as a component.
-pub trait ComponentFunction ComponentFunction for Component {
- type Props = P;
+impl for Component {
fn as_component(self: Rc {
self.as_ref().clone()
}
}
/// Accept any callbacks that take props
-impl for F {
- type Props = P;
+impl for F {
fn as_component(self: Rc {
self
}
@@ -87,7 +89,6 @@ impl for F {
/// Accept any callbacks that take no props
pub struct EmptyMarker;
impl