From 1110026d54733e659bcd2603c7b24e7d18c26526 Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 6 Jul 2023 11:52:17 -0700 Subject: [PATCH] allow nested routers --- packages/router/src/components/router.rs | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) diff --git a/packages/router/src/components/router.rs b/packages/router/src/components/router.rs index 54ac74173..a01250545 100644 --- a/packages/router/src/components/router.rs +++ b/packages/router/src/components/router.rs @@ -121,22 +121,14 @@ where ::Err: std::fmt::Display, { use_context_provider(cx, || { - #[allow(unreachable_code, unused_variables)] - if let Some(outer) = cx.consume_context::>() { - let msg = "Router components should not be nested within each other"; - error!("{msg}, inner will be inactive and transparent"); - #[cfg(debug_assertions)] - panic!("{}", msg); - } - let router = GenericRouterContext::new( + GenericRouterContext::new( (cx.props .config .config .take() .expect("use_context_provider ran twice"))(), cx.schedule_update_any(), - ); - router + ) }); render! { @@ -152,22 +144,14 @@ where R: serde::Serialize + serde::de::DeserializeOwned, { use_context_provider(cx, || { - #[allow(unreachable_code, unused_variables)] - if let Some(outer) = cx.consume_context::>() { - let msg = "Router components should not be nested within each other"; - error!("{msg}, inner will be inactive and transparent"); - #[cfg(debug_assertions)] - panic!("{}", msg); - } - let router = GenericRouterContext::new( + GenericRouterContext::new( (cx.props .config .config .take() .expect("use_context_provider ran twice"))(), cx.schedule_update_any(), - ); - router + ) }); render! {