From 3267ddec1010277bb87b93e1e915b5b01f6c524e Mon Sep 17 00:00:00 2001 From: Evan Almloff Date: Thu, 11 Jan 2024 15:23:37 -0600 Subject: [PATCH] more consistent naming of the root component in core --- packages/core/src/error_boundary.rs | 6 +++--- packages/core/src/fragment.rs | 2 +- packages/core/src/scope_context.rs | 2 +- packages/core/src/virtual_dom.rs | 16 ++++++++-------- packages/core/tests/create_passthru.rs | 12 ++++++------ packages/core/tests/miri_full_app.rs | 4 ++-- packages/core/tests/miri_simple.rs | 20 ++++++++++---------- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/packages/core/src/error_boundary.rs b/packages/core/src/error_boundary.rs index 7ea426048..195b6f38d 100644 --- a/packages/core/src/error_boundary.rs +++ b/packages/core/src/error_boundary.rs @@ -139,7 +139,7 @@ impl ErrorBoundary { /// /// ```rust, ignore /// #[component] -/// fn App( count: String) -> Element { +/// fn app( count: String) -> Element { /// let id: i32 = count.parse().throw()?; /// /// cx.render(rsx! { @@ -164,7 +164,7 @@ pub trait Throw: Sized { /// /// ```rust, ignore /// #[component] - /// fn App( count: String) -> Element { + /// fn app( count: String) -> Element { /// let id: i32 = count.parse().throw()?; /// /// cx.render(rsx! { @@ -187,7 +187,7 @@ pub trait Throw: Sized { /// /// ```rust, ignore /// #[component] - /// fn App( count: String) -> Element { + /// fn app( count: String) -> Element { /// let id: i32 = count.parse().throw()?; /// /// cx.render(rsx! { diff --git a/packages/core/src/fragment.rs b/packages/core/src/fragment.rs index 05dec6fda..91a034f07 100644 --- a/packages/core/src/fragment.rs +++ b/packages/core/src/fragment.rs @@ -62,7 +62,7 @@ impl FragmentBuilder { /// ## Example /// /// ```rust, ignore -/// fn App() -> Element { +/// fn app() -> Element { /// cx.render(rsx!{ /// CustomCard { /// h1 {} diff --git a/packages/core/src/scope_context.rs b/packages/core/src/scope_context.rs index f01e43f11..bd0700ec7 100644 --- a/packages/core/src/scope_context.rs +++ b/packages/core/src/scope_context.rs @@ -158,7 +158,7 @@ impl ScopeContext { /// ```rust, ignore /// struct SharedState(&'static str); /// - /// static App: Component = |cx| { + /// static app: Component = |cx| { /// cx.use_hook(|| cx.provide_context(SharedState("world"))); /// render!(Child {}) /// } diff --git a/packages/core/src/virtual_dom.rs b/packages/core/src/virtual_dom.rs index 90415416e..07d81415c 100644 --- a/packages/core/src/virtual_dom.rs +++ b/packages/core/src/virtual_dom.rs @@ -34,7 +34,7 @@ use std::{any::Any, cell::Cell, collections::BTreeSet, future::Future, rc::Rc}; /// title: String /// } /// -/// fn App(cx: AppProps) -> Element { +/// fn app(cx: AppProps) -> Element { /// cx.render(rsx!( /// div {"hello, {cx.title}"} /// )) @@ -55,7 +55,7 @@ use std::{any::Any, cell::Cell, collections::BTreeSet, future::Future, rc::Rc}; /// static ROUTES: &str = ""; /// /// #[component] -/// fn App(cx: AppProps) -> Element { +/// fn app(cx: AppProps) -> Element { /// cx.render(rsx!( /// NavBar { routes: ROUTES } /// Title { "{cx.title}" } @@ -88,9 +88,9 @@ use std::{any::Any, cell::Cell, collections::BTreeSet, future::Future, rc::Rc}; /// /// ```rust /// # use dioxus::prelude::*; -/// # fn App() -> Element { cx.render(rsx! { div {} }) } +/// # fn app() -> Element { cx.render(rsx! { div {} }) } /// -/// let mut vdom = VirtualDom::new(App); +/// let mut vdom = VirtualDom::new(app); /// let edits = vdom.rebuild(); /// ``` /// @@ -127,13 +127,13 @@ 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() -> Element { +/// fn app() -> Element { /// cx.render(rsx! { /// div { "Hello World" } /// }) /// } /// -/// let dom = VirtualDom::new(App); +/// let dom = VirtualDom::new(app); /// /// real_dom.apply(dom.rebuild()); /// @@ -464,7 +464,7 @@ impl VirtualDom { /// # Example /// /// ```rust, ignore - /// let dom = VirtualDom::new(App); + /// let dom = VirtualDom::new(app); /// let sender = dom.get_scheduler_channel(); /// ``` pub async fn wait_for_work(&mut self) { @@ -545,7 +545,7 @@ impl VirtualDom { /// /// # Example /// ```rust, ignore - /// static App: Component = |cx| cx.render(rsx!{ "hello world" }); + /// static app: Component = |cx| cx.render(rsx!{ "hello world" }); /// /// let mut dom = VirtualDom::new(); /// let edits = dom.rebuild(); diff --git a/packages/core/tests/create_passthru.rs b/packages/core/tests/create_passthru.rs index c7f0090b4..ac8b16c38 100644 --- a/packages/core/tests/create_passthru.rs +++ b/packages/core/tests/create_passthru.rs @@ -5,7 +5,7 @@ use dioxus_core::ElementId; /// Should push the text node onto the stack and modify it #[test] fn nested_passthru_creates() { - fn App() -> Element { + fn app() -> Element { render! { PassThru { PassThru { @@ -20,7 +20,7 @@ fn nested_passthru_creates() { render!(children) } - let mut dom = VirtualDom::new(App); + let mut dom = VirtualDom::new(app); let edits = dom.rebuild_to_vec().santize(); assert_eq!( @@ -37,7 +37,7 @@ fn nested_passthru_creates() { /// Take note on how we don't spit out the template for child_comp since it's entirely dynamic #[test] fn nested_passthru_creates_add() { - fn App() -> Element { + fn app() -> Element { render! { ChildComp { "1" @@ -57,7 +57,7 @@ fn nested_passthru_creates_add() { render! {children} } - let mut dom = VirtualDom::new(App); + let mut dom = VirtualDom::new(app); assert_eq!( dom.rebuild_to_vec().santize().edits, @@ -78,13 +78,13 @@ fn nested_passthru_creates_add() { /// note that the template is all dynamic roots - so it doesn't actually get cached as a template #[test] fn dynamic_node_as_root() { - fn App() -> Element { + fn app() -> Element { let a = 123; let b = 456; render! { "{a}", "{b}" } } - let mut dom = VirtualDom::new(App); + let mut dom = VirtualDom::new(app); let edits = dom.rebuild_to_vec().santize(); // Since the roots were all dynamic, they should not cause any template muations diff --git a/packages/core/tests/miri_full_app.rs b/packages/core/tests/miri_full_app.rs index b8ad213e0..8ccdc8f56 100644 --- a/packages/core/tests/miri_full_app.rs +++ b/packages/core/tests/miri_full_app.rs @@ -7,7 +7,7 @@ use std::rc::Rc; #[test] fn miri_rollover() { set_event_converter(Box::new(SerializedHtmlEventConverter)); - let mut dom = VirtualDom::new(App); + let mut dom = VirtualDom::new(app); _ = dom.rebuild(&mut dioxus_core::NoOpMutations); @@ -23,7 +23,7 @@ fn miri_rollover() { } } -fn App() -> Element { +fn app() -> Element { let mut idx = use_signal(|| 0); let onhover = |_| println!("go!"); diff --git a/packages/core/tests/miri_simple.rs b/packages/core/tests/miri_simple.rs index c3d602bad..8a6134e11 100644 --- a/packages/core/tests/miri_simple.rs +++ b/packages/core/tests/miri_simple.rs @@ -2,11 +2,11 @@ use dioxus::prelude::*; #[test] fn app_drops() { - fn App() -> Element { + fn app() -> Element { render! { div {} } } - let mut dom = VirtualDom::new(App); + let mut dom = VirtualDom::new(app); _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); @@ -15,7 +15,7 @@ fn app_drops() { #[test] fn hooks_drop() { - fn App() -> Element { + fn app() -> Element { once(|| String::from("asd")); once(|| String::from("asd")); once(|| String::from("asd")); @@ -24,7 +24,7 @@ fn hooks_drop() { render! { div {} } } - let mut dom = VirtualDom::new(App); + let mut dom = VirtualDom::new(app); _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); @@ -33,7 +33,7 @@ fn hooks_drop() { #[test] fn contexts_drop() { - fn App() -> Element { + fn app() -> Element { provide_context(String::from("asd")); render! { @@ -47,7 +47,7 @@ fn contexts_drop() { render! { div { "hello {el}" } } } - let mut dom = VirtualDom::new(App); + let mut dom = VirtualDom::new(app); _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); @@ -56,7 +56,7 @@ fn contexts_drop() { #[test] fn tasks_drop() { - fn App() -> Element { + fn app() -> Element { spawn(async { // tokio::time::sleep(std::time::Duration::from_millis(100000)).await; }); @@ -64,7 +64,7 @@ fn tasks_drop() { render! { div {} } } - let mut dom = VirtualDom::new(App); + let mut dom = VirtualDom::new(app); _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT); @@ -88,7 +88,7 @@ fn root_props_drop() { #[test] fn diffing_drops_old() { - fn App() -> Element { + fn app() -> Element { render! { div { match generation() % 2 { @@ -110,7 +110,7 @@ fn diffing_drops_old() { render! {"Goodbye {name}"} } - let mut dom = VirtualDom::new(App); + let mut dom = VirtualDom::new(app); _ = dom.rebuild(&mut dioxus_core::NoOpMutations); dom.mark_dirty(ScopeId::ROOT);