feat: Opt-out html in dioxus-router (#4217)
* feat: Opt-out `html` in `dioxus-router` * typo: Enable html by default * Fix cargo doc on html --------- Co-authored-by: Jonathan Kelley <jkelleyrtp@gmail.com>
This commit is contained in:
1 parent
7f44a09b38
commit
db3ce07030
4 files changed
+30
-8
No files matched your search
@@ -1,4 +1,4 @@
|
||||
use crate::{components::FailureExternalNavigation, prelude::*};
|
||||
use crate::prelude::*;
|
||||
use dioxus_lib::prelude::*;
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -31,10 +31,21 @@ pub struct RouterConfig<R> {
|
||||
pub(crate) on_update: Option<RoutingCallback<R>>,
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "html"))]
|
||||
impl<R> Default for RouterConfig<R> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
failure_external_navigation: FailureExternalNavigation,
|
||||
failure_external_navigation: || VNode::empty(),
|
||||
on_update: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "html")]
|
||||
impl<R> Default for RouterConfig<R> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
failure_external_navigation: crate::components::FailureExternalNavigation,
|
||||
on_update: None,
|
||||
}
|
||||
}
|
||||
@@ -69,7 +80,10 @@ where
|
||||
|
||||
/// A component to render when an external navigation fails.
|
||||
///
|
||||
/// Defaults to a router-internal component called [`FailureExternalNavigation`]
|
||||
#[cfg_attr(
|
||||
feature = "html",
|
||||
doc = "Defaults to [`crate::components::FailureExternalNavigation`]."
|
||||
)]
|
||||
pub fn failure_external_navigation(self, component: fn() -> Element) -> Self {
|
||||
Self {
|
||||
failure_external_navigation: component,
|
||||
|
||||
Reference in new issue
Block a user