diff --git a/examples/control_focus.rs b/examples/control_focus.rs index ac4e20418..f161652f0 100644 --- a/examples/control_focus.rs +++ b/examples/control_focus.rs @@ -15,7 +15,7 @@ fn app(cx: Scope) -> Element { if *running.current() { loop { tokio::time::sleep(std::time::Duration::from_millis(10)).await; - if let Some(element) = elements.read().get(focused) { + if let Some(element) = elements.with(|f| f.get(focused).cloned()) { _ = element.set_focus(true).await; } else { focused = 0; diff --git a/examples/scroll_to_top.rs b/examples/scroll_to_top.rs index 4159fd67a..eed0a00b5 100644 --- a/examples/scroll_to_top.rs +++ b/examples/scroll_to_top.rs @@ -22,8 +22,10 @@ fn app(cx: Scope) -> Element { button { onclick: move |_| { - if let Some(header) = header_element.read().as_ref() { - _ = header.scroll_to(ScrollBehavior::Smooth); + if let Some(header) = header_element.read().as_ref().cloned() { + cx.spawn(async move { + let _ = header.scroll_to(ScrollBehavior::Smooth).await; + }); } }, "Scroll to top" diff --git a/packages/core/src/nodes.rs b/packages/core/src/nodes.rs index 98964e948..01812bef5 100644 --- a/packages/core/src/nodes.rs +++ b/packages/core/src/nodes.rs @@ -868,7 +868,7 @@ where nodes.extend(self.into_iter().map(|node| node.into_vnode(cx))); match nodes.into_bump_slice() { - children if children.is_empty() => DynamicNode::default(), + [] => DynamicNode::default(), children => DynamicNode::Fragment(children), } } diff --git a/packages/core/src/scope_context.rs b/packages/core/src/scope_context.rs index ffb9e74a1..b7c6d8404 100644 --- a/packages/core/src/scope_context.rs +++ b/packages/core/src/scope_context.rs @@ -117,7 +117,7 @@ impl ScopeContext { } let mut search_parent = self.parent_id; - match with_runtime(|runtime: &crate::runtime::Runtime| { + let cur_runtime = with_runtime(|runtime: &crate::runtime::Runtime| { while let Some(parent_id) = search_parent { let parent = runtime.get_context(parent_id).unwrap(); tracing::trace!( @@ -135,9 +135,9 @@ impl ScopeContext { search_parent = parent.parent_id; } None - }) - .flatten() - { + }); + + match cur_runtime.flatten() { Some(ctx) => Some(ctx), None => { tracing::trace!( diff --git a/packages/core/tests/create_fragments.rs b/packages/core/tests/create_fragments.rs index fff90464a..8269320ae 100644 --- a/packages/core/tests/create_fragments.rs +++ b/packages/core/tests/create_fragments.rs @@ -7,7 +7,7 @@ use dioxus_core::ElementId; #[test] fn empty_fragment_creates_nothing() { fn app(cx: Scope) -> Element { - cx.render(rsx!({ () })) + cx.render(rsx!({})) } let mut vdom = VirtualDom::new(app); diff --git a/packages/core/tests/miri_stress.rs b/packages/core/tests/miri_stress.rs index f571b30ce..aad596e82 100644 --- a/packages/core/tests/miri_stress.rs +++ b/packages/core/tests/miri_stress.rs @@ -15,7 +15,7 @@ fn test_memory_leak() { cx.spawn(async {}); if val == 2 || val == 4 { - return render!({ () }); + return render!({}); } let name = cx.use_hook(|| String::from("numbers: ")); diff --git a/packages/rsx/src/component.rs b/packages/rsx/src/component.rs index 528a39072..c7f4c1828 100644 --- a/packages/rsx/src/component.rs +++ b/packages/rsx/src/component.rs @@ -53,20 +53,15 @@ impl Parse for Component { if content.peek(Token![..]) { content.parse::()?; manual_props = Some(content.parse()?); - } else - // - // Fields + } else if // Named fields - if content.peek(Ident) && content.peek2(Token![:]) && !content.peek3(Token![:]) { - fields.push(content.parse()?); - } else - // + (content.peek(Ident) && content.peek2(Token![:]) && !content.peek3(Token![:])) // shorthand struct initialization - // Not a div {}, mod::Component {}, or web-component {} - if content.peek(Ident) - && !content.peek2(Brace) - && !content.peek2(Token![:]) - && !content.peek2(Token![-]) + // Not a div {}, mod::Component {}, or web-component {} + || (content.peek(Ident) + && !content.peek2(Brace) + && !content.peek2(Token![:]) + && !content.peek2(Token![-])) { fields.push(content.parse()?); } else { diff --git a/packages/ssr/tests/simple.rs b/packages/ssr/tests/simple.rs index 9e4a2e2b0..bc90e9ee6 100644 --- a/packages/ssr/tests/simple.rs +++ b/packages/ssr/tests/simple.rs @@ -68,7 +68,7 @@ fn fragments() { dioxus_ssr::render_lazy(rsx! { div { for _ in 0..5 { - {()} + {} } } }),