add component support

This commit is contained in:
Evan Almloff committed 2022-05-27 09:47:44 -05:00
1 parent 07da854455
commit a0c7e4d78a
8 files changed
+62 -14

No files matched your search

+18 -1
View File
@@ -21,7 +21,24 @@ fn app(cx: Scope) -> Element {
cx.render(rsx! {
h1 {
width: format!("{}px", count),
"High-Five counter: {count}"
"High-Five counter: {count}",
Comp{
color: "#083289"
}
}
})
}
#[derive(PartialEq, Props)]
struct CompProps {
color: &'static str,
}
fn Comp(cx: Scope<CompProps>) -> Element {
cx.render(rsx! {
h1 {
color: cx.props.color,
"Hello, from a component!"
}
})
}