diff --git a/packages/core/src/component.rs b/packages/core/src/component.rs index 45c6cf6a2..6c62e9ce7 100644 --- a/packages/core/src/component.rs +++ b/packages/core/src/component.rs @@ -6,6 +6,7 @@ //! that ensures compile-time required and optional fields on props. use crate::innerlude::FC; + pub type ScopeIdx = generational_arena::Index; pub trait Properties: PartialEq { diff --git a/packages/core/src/context.rs b/packages/core/src/context.rs index f716c080b..49889d576 100644 --- a/packages/core/src/context.rs +++ b/packages/core/src/context.rs @@ -2,10 +2,7 @@ use crate::nodes::VNode; use crate::prelude::*; use bumpalo::Bump; use hooks::Hook; -use std::{ - any::TypeId, borrow::Borrow, cell::RefCell, future::Future, marker::PhantomData, ops::Deref, - rc::Rc, sync::atomic::AtomicUsize, -}; +use std::{cell::RefCell, future::Future, ops::Deref, rc::Rc, sync::atomic::AtomicUsize}; /// Components in Dioxus use the "Context" object to interact with their lifecycle. /// This lets components schedule updates, integrate hooks, and expose their context via the context api. @@ -19,7 +16,7 @@ use std::{ /// /// } /// -/// fn example(ctx: &Context) -> VNode { +/// fn example(ctx: Context, props: &Props -> VNode { /// html! { ///
"Hello, {ctx.props.name}"
/// } @@ -47,7 +44,6 @@ pub struct Context<'src> { } impl<'a> Context<'a> { - // impl<'a, PropType> Context<'a, PropType> { /// Access the children elements passed into the component pub fn children(&self) -> Vec { todo!("Children API not yet implemented for component Context") @@ -55,10 +51,12 @@ impl<'a> Context<'a> { pub fn callback(&self, _f: impl Fn(()) + 'a) {} + // call this closure after the component has been committed to the editlist + // this provides the founation of "use_effect" + fn post_update() {} + /// Create a subscription that schedules a future render for the reference component pub fn schedule_update(&self) -> impl Fn() -> () { - // log::debug!() - // todo!("Subscription API is not ready yet"); || {} } @@ -93,7 +91,7 @@ impl<'a> Context<'a> { /// ```ignore /// fn Component(ctx: Context) -> VNode { /// // Lazy assemble the VNode tree - /// let lazy_tree = html! {
"Hello World"
}; + /// let lazy_tree = html! {
"Hello World"
}; /// /// // Actually build the tree and allocate it /// ctx.render(lazy_tree)