make the root component take no arguments
This commit is contained in:
1 parent
8fe2515413
commit
404c864246
26 files changed
+46
-47
No files matched your search
@@ -2,7 +2,7 @@
|
||||
|
||||
use dioxus::prelude::*;
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
let raw = match generation() % 2 {
|
||||
0 => "123.123",
|
||||
1 => "123.123.123",
|
||||
|
||||
@@ -3,7 +3,7 @@ use dioxus::prelude::*;
|
||||
|
||||
#[test]
|
||||
fn state_shares() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
cx.provide_context(generation() as i32);
|
||||
|
||||
render!(child_1 {})
|
||||
|
||||
@@ -6,7 +6,7 @@ use dioxus_core::ElementId;
|
||||
|
||||
#[test]
|
||||
fn empty_fragment_creates_nothing() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
render!(())
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ fn fragments_nested() {
|
||||
|
||||
#[test]
|
||||
fn fragments_across_components() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
render! {
|
||||
demo_child {}
|
||||
demo_child {}
|
||||
@@ -88,7 +88,7 @@ fn fragments_across_components() {
|
||||
|
||||
#[test]
|
||||
fn list_fragments() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
render!(
|
||||
h1 { "hello" }
|
||||
(0..6).map(|f| render!( span { "{f}" }))
|
||||
|
||||
@@ -8,7 +8,7 @@ use dioxus_core::ElementId;
|
||||
// In Dioxus, we memoize the render! body and simplify it down to a few template loads
|
||||
//
|
||||
// Also note that the IDs increase linearly. This lets us drive a vec on the renderer for O(1) re-indexing
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
render! {
|
||||
div {
|
||||
(0..3).map(|i| render! {
|
||||
|
||||
@@ -6,7 +6,7 @@ use dioxus_core::ElementId;
|
||||
#[test]
|
||||
fn nested_passthru_creates() {
|
||||
#[component]
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
render! {
|
||||
PassThru {
|
||||
PassThru {
|
||||
@@ -39,7 +39,7 @@ fn nested_passthru_creates() {
|
||||
#[test]
|
||||
fn nested_passthru_creates_add() {
|
||||
#[component]
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
render! {
|
||||
ChildComp {
|
||||
"1"
|
||||
@@ -81,7 +81,7 @@ fn nested_passthru_creates_add() {
|
||||
#[test]
|
||||
fn dynamic_node_as_root() {
|
||||
#[component]
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
let a = 123;
|
||||
let b = 456;
|
||||
render! { "{a}", "{b}" }
|
||||
|
||||
@@ -7,7 +7,7 @@ use dioxus::prelude::*;
|
||||
/// different pointers
|
||||
#[test]
|
||||
fn component_swap() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
let render_phase = cx.use_hook(|| 0);
|
||||
|
||||
*render_phase += 1;
|
||||
|
||||
@@ -4,7 +4,7 @@ use dioxus_core::ElementId;
|
||||
|
||||
#[test]
|
||||
fn text_diff() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
let gen = generation();
|
||||
render!( h1 { "hello {gen}" } )
|
||||
}
|
||||
@@ -33,7 +33,7 @@ fn text_diff() {
|
||||
|
||||
#[test]
|
||||
fn element_swap() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
let gen = generation();
|
||||
|
||||
match gen % 2 {
|
||||
|
||||
@@ -8,7 +8,7 @@ fn catches_panic() {
|
||||
_ = dom.rebuild_to_vec(&mut dioxus_core::NoOpMutations);
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
render! {
|
||||
div {
|
||||
h1 { "Title" }
|
||||
|
||||
@@ -51,7 +51,7 @@ fn events_propagate() {
|
||||
assert_eq!(*CLICKS.lock().unwrap(), 3);
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
render! {
|
||||
div { onclick: move |_| {
|
||||
println!("top clicked");
|
||||
|
||||
@@ -41,7 +41,7 @@ fn manual_diffing() {
|
||||
#[test]
|
||||
fn events_generate() {
|
||||
set_event_converter(Box::new(SerializedHtmlEventConverter));
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
let count = cx.use_hook(|| 0);
|
||||
|
||||
match *count {
|
||||
@@ -79,7 +79,7 @@ fn events_generate() {
|
||||
|
||||
// #[test]
|
||||
// fn components_generate() {
|
||||
// fn app(cx: Scope) -> Element {
|
||||
// fn app() -> Element {
|
||||
// let render_phase = cx.use_hook(|| 0);
|
||||
// *render_phase += 1;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ fn miri_rollover() {
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
let mut idx = use_state(cx, || 0);
|
||||
let onhover = |_| println!("go!");
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ use dioxus::prelude::*;
|
||||
#[test]
|
||||
fn app_drops() {
|
||||
#[component]
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
render! { div {} }
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ fn app_drops() {
|
||||
#[test]
|
||||
fn hooks_drop() {
|
||||
#[component]
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
cx.use_hook(|| String::from("asd"));
|
||||
cx.use_hook(|| String::from("asd"));
|
||||
cx.use_hook(|| String::from("asd"));
|
||||
@@ -36,7 +36,7 @@ fn hooks_drop() {
|
||||
#[test]
|
||||
fn contexts_drop() {
|
||||
#[component]
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
cx.provide_context(String::from("asd"));
|
||||
|
||||
render! {
|
||||
@@ -61,7 +61,7 @@ fn contexts_drop() {
|
||||
#[test]
|
||||
fn tasks_drop() {
|
||||
#[component]
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
cx.spawn(async {
|
||||
// tokio::time::sleep(std::time::Duration::from_millis(100000)).await;
|
||||
});
|
||||
@@ -93,7 +93,7 @@ fn root_props_drop() {
|
||||
#[test]
|
||||
fn diffing_drops_old() {
|
||||
#[component]
|
||||
fn App(cx: Scope) -> Element {
|
||||
fn App() -> Element {
|
||||
render! {
|
||||
div {
|
||||
match generation() % 2 {
|
||||
|
||||
@@ -9,7 +9,7 @@ use dioxus::prelude::*;
|
||||
/// When miri runs, it'll let us know if we leaked or aliased.
|
||||
#[test]
|
||||
fn test_memory_leak() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
let val = generation();
|
||||
|
||||
cx.spawn(async {});
|
||||
@@ -69,7 +69,7 @@ fn test_memory_leak() {
|
||||
|
||||
#[test]
|
||||
fn memo_works_properly() {
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
let val = generation();
|
||||
|
||||
if val == 2 || val == 4 {
|
||||
@@ -142,7 +142,7 @@ fn supports_async() {
|
||||
use std::time::Duration;
|
||||
use tokio::time::sleep;
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
let colors = use_state(cx, || vec!["green", "blue", "red"]);
|
||||
let padding = use_state(cx, || 10);
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ fn it_works() {
|
||||
});
|
||||
}
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
render!(
|
||||
div {
|
||||
"Waiting for... "
|
||||
|
||||
@@ -8,7 +8,7 @@ async fn it_works() {
|
||||
|
||||
static POLL_COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
|
||||
fn app(cx: Scope) -> Element {
|
||||
fn app() -> Element {
|
||||
cx.use_hook(|| {
|
||||
cx.spawn(async {
|
||||
for x in 0..10 {
|
||||
|
||||
Reference in new issue
Block a user