use std::{cell::RefCell, rc::Rc};
use crate::use_route;
use leptos::*;
#[component]
pub fn Outlet(cx: Scope) -> Child {
let route = use_route(cx);
let is_showing = Rc::new(RefCell::new(None));
let (outlet, set_outlet) = create_signal(cx, None);
create_effect(cx, move |_| {
let is_showing_val = { is_showing.borrow().clone() };
let child = route.child();
match (route.child(), &is_showing_val) {
(None, _) => {
set_outlet.set(None);
}
(Some(child), Some(path))
if Some(child.original_path().to_string()) == is_showing_val =>
{
}
(Some(child), _) => {
*is_showing.borrow_mut() = Some(child.original_path().to_string());
provide_context(child.cx(), child.clone());
set_outlet.set(Some(child.outlet().into_child(cx)))
}
}
});
(move || outlet.get()).into_child(cx)
}