make the root component take no arguments

This commit is contained in:
Evan Almloff committed 2024-01-11 10:48:04 -06:00
1 parent 8fe2515413
commit 404c864246
26 files changed
+46 -47

No files matched your search

+1 -1
View File
@@ -62,7 +62,7 @@ impl<const A: bool> FragmentBuilder<A> {
/// ## Example
///
/// ```rust, ignore
/// fn App(cx: Scope) -> Element {
/// fn App() -> Element {
/// cx.render(rsx!{
/// CustomCard {
/// h1 {}
+1 -1
View File
@@ -115,7 +115,7 @@ impl Runtime {
/// let virtual_dom = VirtualDom::new(app);
/// }
///
/// fn app(cx: Scope) -> Element {
/// fn app() -> Element {
/// render!{ Component { runtime: Runtime::current().unwrap() } }
/// }
///
+4 -7
View File
@@ -88,7 +88,7 @@ use std::{any::Any, cell::Cell, collections::BTreeSet, future::Future, rc::Rc};
///
/// ```rust
/// # use dioxus::prelude::*;
/// # fn App(cx: Scope) -> Element { cx.render(rsx! { div {} }) }
/// # fn App() -> Element { cx.render(rsx! { div {} }) }
///
/// let mut vdom = VirtualDom::new(App);
/// let edits = vdom.rebuild();
@@ -127,7 +127,7 @@ use std::{any::Any, cell::Cell, collections::BTreeSet, future::Future, rc::Rc};
/// Putting everything together, you can build an event loop around Dioxus by using the methods outlined above.
/// ```rust, ignore
/// #[component]
/// fn App(cx: Scope) -> Element {
/// fn App() -> Element {
/// cx.render(rsx! {
/// div { "Hello World" }
/// })
@@ -226,8 +226,8 @@ impl VirtualDom {
/// ```
///
/// Note: the VirtualDom is not progressed, you must either "run_with_deadline" or use "rebuild" to progress it.
pub fn new(app: fn(()) -> Element) -> Self {
Self::new_with_props(app, ())
pub fn new(app: fn() -> Element) -> Self {
Self::new_with_props(|app| app(), app)
}
/// Create a new VirtualDom with the given properties for the root component.
@@ -563,7 +563,6 @@ impl VirtualDom {
to.append_children(ElementId(0), m);
}
#[cfg(features = "internal-testing")]
/// [`VirtualDom::rebuild`] to a vector of mutations for testing purposes
pub fn rebuild_to_vec(&mut self) -> MutationsVec {
let mut mutations = MutationsVec::default();
@@ -590,7 +589,6 @@ impl VirtualDom {
}
}
#[cfg(features = "internal-testing")]
/// [`Self::render_immediate`] to a vector of mutations for testing purposes
pub fn render_immediate_to_vec(&mut self) -> MutationsVec {
let mut mutations = MutationsVec::default();
@@ -662,7 +660,6 @@ impl VirtualDom {
}
}
#[cfg(features = "internal-testing")]
/// [`Self::render_with_deadline`] to a vector of mutations for testing purposes
pub async fn render_with_deadline_to_vec(
&mut self,