mirror of
https://github.com/DioxusLabs/dioxus
synced 2025-02-17 06:08:26 +00:00
fix variance on components
This commit is contained in:
parent
92a8669e14
commit
b4983706ac
1 changed files with 5 additions and 4 deletions
|
@ -481,19 +481,20 @@ impl<'src> ScopeState {
|
||||||
/// fn(Scope<Props>) -> Element;
|
/// fn(Scope<Props>) -> Element;
|
||||||
/// async fn(Scope<Props<'_>>) -> Element;
|
/// async fn(Scope<Props<'_>>) -> Element;
|
||||||
/// ```
|
/// ```
|
||||||
pub fn component<P>(
|
pub fn component<'child, P>(
|
||||||
&'src self,
|
&'src self,
|
||||||
component: fn(Scope<'src, P>) -> Element<'src>,
|
component: fn(Scope<'child, P>) -> Element<'child>,
|
||||||
props: P,
|
props: P,
|
||||||
fn_name: &'static str,
|
fn_name: &'static str,
|
||||||
) -> DynamicNode<'src>
|
) -> DynamicNode<'src>
|
||||||
where
|
where
|
||||||
P: Properties + 'src,
|
P: Properties + 'child,
|
||||||
|
'src: 'child,
|
||||||
{
|
{
|
||||||
let vcomp = VProps::new(component, P::memoize, props);
|
let vcomp = VProps::new(component, P::memoize, props);
|
||||||
|
|
||||||
// cast off the lifetime of the render return
|
// cast off the lifetime of the render return
|
||||||
let as_dyn: Box<dyn AnyProps<'src> + '_> = Box::new(vcomp);
|
let as_dyn: Box<dyn AnyProps<'child> + '_> = Box::new(vcomp);
|
||||||
let extended: Box<dyn AnyProps<'src> + 'src> = unsafe { std::mem::transmute(as_dyn) };
|
let extended: Box<dyn AnyProps<'src> + 'src> = unsafe { std::mem::transmute(as_dyn) };
|
||||||
|
|
||||||
DynamicNode::Component(VComponent {
|
DynamicNode::Component(VComponent {
|
||||||
|
|
Loading…
Add table
Reference in a new issue