Feat: some code health

This commit is contained in:
Jonathan Kelley committed 2021-05-16 02:06:02 -04:00
1 parent 9810feebf5
commit c28697e1fe
16 files changed
+568 -551

No files matched your search

+19 -4
View File
@@ -22,7 +22,7 @@ struct ExampleProps {
}
static Example: FC<ExampleProps> = |ctx, props| {
let name = use_state_new(&ctx, move || props.initial_name.to_string());
let name = use_state_new(&ctx, move || props.initial_name);
ctx.render(rsx! {
div {
@@ -36,9 +36,11 @@ static Example: FC<ExampleProps> = |ctx, props| {
"Hello, {name}"
}
CustomButton { name: "Jack!", handler: move |_| name.set("Jack".to_string()) }
CustomButton { name: "Jill!", handler: move |_| name.set("Jill".to_string()) }
CustomButton { name: "Bob!", handler: move |_| name.set("Bob".to_string())}
CustomButton { name: "Jack!", handler: move |_| name.set("Jack") }
CustomButton { name: "Jill!", handler: move |_| name.set("Jill") }
CustomButton { name: "Bob!", handler: move |_| name.set("Bob")}
Placeholder {val: name}
Placeholder {val: name}
}
})
};
@@ -66,3 +68,16 @@ impl<F: Fn(MouseEvent)> PartialEq for ButtonProps<'_, F> {
false
}
}
#[derive(Props, PartialEq)]
struct PlaceholderProps {
val: &'static str
}
fn Placeholder(ctx: Context, props: &PlaceholderProps) -> DomTree {
ctx.render(rsx!{
div {
"child: {props.val}"
}
})
}