Fix the router and stub out a number of crates to get compiling
This commit is contained in:
226 files changed
+1057
-1482
No files matched your search
@@ -16,34 +16,31 @@ impl<R> Clone for OutletContext<R> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn use_outlet_context<R: 'static>(cx: &ScopeState) -> &OutletContext<R> {
|
||||
let outlet_context = cx.use_hook(|| {
|
||||
cx.consume_context().unwrap_or(OutletContext::<R> {
|
||||
pub(crate) fn use_outlet_context<R: 'static>() -> OutletContext<R> {
|
||||
use_hook(|| {
|
||||
consume_context().unwrap_or(OutletContext::<R> {
|
||||
current_level: 1,
|
||||
_marker: std::marker::PhantomData,
|
||||
})
|
||||
});
|
||||
outlet_context
|
||||
})
|
||||
}
|
||||
|
||||
impl<R> OutletContext<R> {
|
||||
pub(crate) fn render(cx: Scope) -> Element<'_>
|
||||
pub(crate) fn render() -> Element
|
||||
where
|
||||
R: Routable + Clone,
|
||||
{
|
||||
let router = use_router_internal(cx)
|
||||
.as_ref()
|
||||
.expect("Outlet must be inside of a router");
|
||||
let outlet: &OutletContext<R> = use_outlet_context(cx);
|
||||
let router = use_router_internal().expect("Outlet must be inside of a router");
|
||||
let outlet: OutletContext<R> = use_outlet_context();
|
||||
let current_level = outlet.current_level;
|
||||
cx.provide_context({
|
||||
provide_context({
|
||||
OutletContext::<R> {
|
||||
current_level: current_level + 1,
|
||||
_marker: std::marker::PhantomData,
|
||||
}
|
||||
});
|
||||
|
||||
if let Some(error) = router.render_error(cx) {
|
||||
if let Some(error) = router.render_error() {
|
||||
if current_level == 0 {
|
||||
return Some(error);
|
||||
} else {
|
||||
@@ -51,6 +48,6 @@ impl<R> OutletContext<R> {
|
||||
}
|
||||
}
|
||||
|
||||
router.current::<R>().render(cx, current_level)
|
||||
router.current::<R>().render(current_level)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user