allow configering the root name in the desktop renderer

This commit is contained in:
Evan Almloff committed 2022-12-18 22:28:40 -06:00
1 parent a42660a451
commit f84166fb11
4 files changed
+27 -9

No files matched your search

+10
View File
@@ -21,6 +21,7 @@ pub struct Config {
pub(crate) resource_dir: Option<PathBuf>,
pub(crate) custom_head: Option<String>,
pub(crate) custom_index: Option<String>,
pub(crate) root_name: String,
}
type DropHandler = Box<dyn Fn(&Window, FileDropEvent) -> bool>;
@@ -46,6 +47,7 @@ impl Config {
resource_dir: None,
custom_head: None,
custom_index: None,
root_name: "main".to_string(),
}
}
@@ -126,6 +128,14 @@ impl Config {
self.custom_index = Some(index);
self
}
/// Set the name of the element that Dioxus will use as the root.
///
/// This is akint to calling React.render() on the element with the specified name.
pub fn with_root_name(mut self, name: impl Into<String>) -> Self {
self.root_name = name.into();
self
}
}
impl Default for Config {