mirror of
https://github.com/DioxusLabs/dioxus
synced 2024-11-23 12:43:08 +00:00
restore core tests
This commit is contained in:
parent
b58eb04278
commit
ad01a45f3b
9 changed files with 19 additions and 11 deletions
|
@ -65,10 +65,18 @@ impl VNode {
|
|||
dom: &mut VirtualDom,
|
||||
to: &mut impl WriteMutations,
|
||||
) {
|
||||
println!(
|
||||
"diffing vcomponent: {new:#?} vs {old:#?}",
|
||||
new = new,
|
||||
old = old
|
||||
);
|
||||
|
||||
// Replace components that have different render fns
|
||||
if old.render_fn != new.render_fn {
|
||||
println!("render fns are different, replacing");
|
||||
return self.replace_vcomponent(mount, idx, new, parent, dom, to);
|
||||
}
|
||||
println!("render fns are the same, continuing");
|
||||
|
||||
// copy out the box for both
|
||||
let old_scope = &mut dom.scopes[scope_id.0];
|
||||
|
|
|
@ -14,7 +14,7 @@ fn state_shares() {
|
|||
}
|
||||
|
||||
fn child_2() -> Element {
|
||||
let value = consume_context::<i32>().unwrap();
|
||||
let value = consume_context::<i32>();
|
||||
rsx!("Value is {value}")
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ fn component_swap() {
|
|||
|
||||
render_phase += 1;
|
||||
|
||||
match *render_phase() {
|
||||
match render_phase() {
|
||||
0 => rsx! {
|
||||
nav_bar {}
|
||||
dash_board {}
|
||||
|
|
|
@ -45,7 +45,7 @@ fn events_generate() {
|
|||
fn app() -> Element {
|
||||
let mut count = use_signal(|| 0);
|
||||
|
||||
match *count() {
|
||||
match count() {
|
||||
0 => rsx! {
|
||||
div { onclick: move |_| count += 1,
|
||||
div { "nested" }
|
||||
|
|
|
@ -38,7 +38,7 @@ fn app() -> Element {
|
|||
}
|
||||
button { onclick: move |_| idx -= 1, "-" }
|
||||
ul {
|
||||
{(0..*idx()).map(|i| rsx! {
|
||||
{(0..idx()).map(|i| rsx! {
|
||||
ChildExample { i: i, onhover: onhover }
|
||||
})}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ fn contexts_drop() {
|
|||
}
|
||||
|
||||
fn ChildComp() -> Element {
|
||||
let el = consume_context::<String>().unwrap();
|
||||
let el = consume_context::<String>();
|
||||
|
||||
rsx! { div { "hello {el}" } }
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ fn root_props_drop() {
|
|||
struct RootProps(String);
|
||||
|
||||
let mut dom = VirtualDom::new_with_props(
|
||||
|cx| rsx!( div { "{cx.0}" } ),
|
||||
|cx: RootProps| rsx!( div { "{cx.0}" } ),
|
||||
RootProps("asdasd".to_string()),
|
||||
);
|
||||
|
||||
|
|
|
@ -144,8 +144,8 @@ fn supports_async() {
|
|||
use tokio::time::sleep;
|
||||
|
||||
fn app() -> Element {
|
||||
let colors = use_signal(|| vec!["green", "blue", "red"]);
|
||||
let padding = use_signal(|| 10);
|
||||
let mut colors = use_signal(|| vec!["green", "blue", "red"]);
|
||||
let mut padding = use_signal(|| 10);
|
||||
|
||||
use_hook(|| {
|
||||
spawn(async move {
|
||||
|
@ -171,7 +171,7 @@ fn supports_async() {
|
|||
})
|
||||
});
|
||||
|
||||
let colors = colors();
|
||||
let colors = colors.read();
|
||||
let big = colors[0];
|
||||
let mid = colors[1];
|
||||
let small = colors[2];
|
||||
|
|
|
@ -31,7 +31,7 @@ fn app() -> Element {
|
|||
fn suspended_child() -> Element {
|
||||
let mut val = use_signal(|| 0);
|
||||
|
||||
if *val() < 3 {
|
||||
if val() < 3 {
|
||||
spawn(async move {
|
||||
val += 1;
|
||||
});
|
||||
|
|
|
@ -201,7 +201,7 @@ impl<'a> ToTokens for TemplateRenderer<'a> {
|
|||
};
|
||||
|
||||
let key_tokens = match key {
|
||||
Some(tok) => quote! { Some( #tok ) },
|
||||
Some(tok) => quote! { Some( #tok.to_string() ) },
|
||||
None => quote! { None },
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue