feat: transition to cx, props
This commit is contained in:
1 parent
f1cff845ce
commit
bfdcb20437
14 files changed
+88
-50
No files matched your search
@@ -27,16 +27,15 @@ use std::{any::TypeId, ops::Deref, rc::Rc};
|
||||
/// }
|
||||
/// }
|
||||
/// ```
|
||||
pub struct Context<'src, T> {
|
||||
pub props: &'src T,
|
||||
pub struct Context<'src> {
|
||||
pub scope: &'src Scope,
|
||||
}
|
||||
|
||||
impl<'src, T> Copy for Context<'src, T> {}
|
||||
impl<'src, T> Clone for Context<'src, T> {
|
||||
impl<'src> Copy for Context<'src> {}
|
||||
impl<'src> Clone for Context<'src> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
props: self.props,
|
||||
// props: self.props,
|
||||
scope: self.scope,
|
||||
}
|
||||
}
|
||||
@@ -44,14 +43,14 @@ impl<'src, T> Clone for Context<'src, T> {
|
||||
|
||||
// We currently deref to props, but it might make more sense to deref to Scope?
|
||||
// This allows for code that takes cx.xyz instead of cx.props.xyz
|
||||
impl<'a, T> Deref for Context<'a, T> {
|
||||
type Target = &'a T;
|
||||
impl<'a> Deref for Context<'a> {
|
||||
type Target = &'a Scope;
|
||||
fn deref(&self) -> &Self::Target {
|
||||
&self.props
|
||||
&self.scope
|
||||
}
|
||||
}
|
||||
|
||||
impl<'src, P> Context<'src, P> {
|
||||
impl<'src> Context<'src> {
|
||||
/// Access the children elements passed into the component
|
||||
///
|
||||
/// This enables patterns where a component is passed children from its parent.
|
||||
|
||||
Reference in new issue
Block a user