use crate::{children::TypedChildren, component, IntoView};
use reactive_graph::owner::{provide_context, Owner};
use tachys::reactive_graph::OwnedView;
#[component]
pub fn Provider<T, Chil>(
value: T,
children: TypedChildren<Chil>,
) -> impl IntoView
where
T: Send + Sync + 'static,
Chil: IntoView + 'static,
{
let owner = Owner::current()
.expect("no current reactive Owner found")
.child();
let children = children.into_inner();
let children = owner.with(|| {
provide_context(value);
children()
});
OwnedView::new_with_owner(children, owner)
}