Skip to content

Commit de85d40

Browse files
committed
harden test case by using an extra inner component
1 parent 17eef46 commit de85d40

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

packages/yew/tests/hydration.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,6 +1083,14 @@ async fn hydrate_flicker() {
10831083
// This components renders the same on the server and client during the first render,
10841084
// but then immediately changes the order of keyed elements in the next render.
10851085
// This should not lead to any hydration failures
1086+
#[derive(Properties, PartialEq)]
1087+
struct InnerCompProps {
1088+
text: String,
1089+
}
1090+
#[component]
1091+
fn InnerComp(InnerCompProps { text }: &InnerCompProps) -> Html {
1092+
html! { <p>{text.clone()}</p> }
1093+
}
10861094
#[component]
10871095
fn Flickering() -> Html {
10881096
let trigger = use_state(|| false);
@@ -1091,15 +1099,15 @@ async fn hydrate_flicker() {
10911099
trigger.set(true);
10921100
html! {
10931101
<>
1094-
<p key="1">{"1"}</p>
1095-
<p key="2">{"2"}</p>
1102+
<InnerComp key="1" text="1" />
1103+
<InnerComp key="2" text="2" />
10961104
</>
10971105
}
10981106
} else {
10991107
html! {
11001108
<>
1101-
<p key="2">{"2"}</p>
1102-
<p key="1">{"1"}</p>
1109+
<InnerComp key="2" text="2" />
1110+
<InnerComp key="1" text="1" />
11031111
</>
11041112
}
11051113
}

0 commit comments

Comments
 (0)