allow nested routers
This commit is contained in:
1 parent
e883e8d0dd
commit
1110026d54
1 file changed
+4
-20
@@ -121,22 +121,14 @@ where
|
|||||||
<R as FromStr>::Err: std::fmt::Display,
|
<R as FromStr>::Err: std::fmt::Display,
|
||||||
{
|
{
|
||||||
use_context_provider(cx, || {
|
use_context_provider(cx, || {
|
||||||
#[allow(unreachable_code, unused_variables)]
|
GenericRouterContext::new(
|
||||||
if let Some(outer) = cx.consume_context::<GenericRouterContext<R>>() {
|
|
||||||
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(
|
|
||||||
(cx.props
|
(cx.props
|
||||||
.config
|
.config
|
||||||
.config
|
.config
|
||||||
.take()
|
.take()
|
||||||
.expect("use_context_provider ran twice"))(),
|
.expect("use_context_provider ran twice"))(),
|
||||||
cx.schedule_update_any(),
|
cx.schedule_update_any(),
|
||||||
);
|
)
|
||||||
router
|
|
||||||
});
|
});
|
||||||
|
|
||||||
render! {
|
render! {
|
||||||
@@ -152,22 +144,14 @@ where
|
|||||||
R: serde::Serialize + serde::de::DeserializeOwned,
|
R: serde::Serialize + serde::de::DeserializeOwned,
|
||||||
{
|
{
|
||||||
use_context_provider(cx, || {
|
use_context_provider(cx, || {
|
||||||
#[allow(unreachable_code, unused_variables)]
|
GenericRouterContext::new(
|
||||||
if let Some(outer) = cx.consume_context::<GenericRouterContext<R>>() {
|
|
||||||
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(
|
|
||||||
(cx.props
|
(cx.props
|
||||||
.config
|
.config
|
||||||
.config
|
.config
|
||||||
.take()
|
.take()
|
||||||
.expect("use_context_provider ran twice"))(),
|
.expect("use_context_provider ran twice"))(),
|
||||||
cx.schedule_update_any(),
|
cx.schedule_update_any(),
|
||||||
);
|
)
|
||||||
router
|
|
||||||
});
|
});
|
||||||
|
|
||||||
render! {
|
render! {
|
||||||
|
|||||||
Reference in new issue
Block a user