Feat: remove old macro
This commit is contained in:
1 parent
e66827ec92
commit
9d0727edab
43 files changed
+208
-2306
No files matched your search
@@ -1,17 +1,19 @@
|
||||
use dioxus_web::{WebsysRenderer, dioxus::prelude::*};
|
||||
use dioxus_web::{dioxus::prelude::*, WebsysRenderer};
|
||||
|
||||
fn main() {
|
||||
wasm_logger::init(wasm_logger::Config::new(log::Level::Debug));
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(CustomA))
|
||||
wasm_bindgen_futures::spawn_local(WebsysRenderer::start(CustomA))
|
||||
}
|
||||
|
||||
use components::CustomB;
|
||||
|
||||
fn CustomA<'a>(ctx: Context<'a>, props: &'a ()) -> DomTree {
|
||||
let (val, set_val) = use_state(&ctx, || "abcdef".to_string());
|
||||
ctx.render(rsx!{
|
||||
ctx.render(rsx! {
|
||||
div {
|
||||
class: "m-8"
|
||||
"CustomA {val}"
|
||||
button {
|
||||
"Upper"
|
||||
@@ -29,35 +31,41 @@ fn CustomA<'a>(ctx: Context<'a>, props: &'a ()) -> DomTree {
|
||||
}
|
||||
|
||||
|
||||
#[derive(Debug, Props, PartialEq)]
|
||||
struct PropsB<'src> {
|
||||
val: &'src str
|
||||
}
|
||||
mod components {
|
||||
use super::*;
|
||||
|
||||
fn CustomB<'a>(ctx: Context<'a>, props: &'a PropsB<'a>) -> DomTree {
|
||||
let (first, last) = props.val.split_at(3);
|
||||
ctx.render(rsx!{
|
||||
div {
|
||||
"CustomB {props.val}"
|
||||
CustomC {
|
||||
val: first
|
||||
#[derive(Debug, Props, PartialEq)]
|
||||
pub struct PropsB<'src> {
|
||||
val: &'src str,
|
||||
}
|
||||
|
||||
pub fn CustomB<'a>(ctx: Context<'a>, props: &'a PropsB<'a>) -> DomTree {
|
||||
let (first, last) = props.val.split_at(3);
|
||||
ctx.render(rsx! {
|
||||
div {
|
||||
class: "m-8"
|
||||
"CustomB {props.val}"
|
||||
CustomC {
|
||||
val: first
|
||||
}
|
||||
CustomC {
|
||||
val: last
|
||||
}
|
||||
}
|
||||
CustomC {
|
||||
val: last
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug, Props, PartialEq)]
|
||||
struct PropsC<'src> {
|
||||
val: &'src str,
|
||||
}
|
||||
|
||||
fn CustomC<'a>(ctx: Context<'a>, props: &'a PropsC<'a>) -> DomTree {
|
||||
ctx.render(rsx! {
|
||||
div {
|
||||
class: "m-8"
|
||||
"CustomC {props.val}"
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
#[derive(Debug, Props, PartialEq)]
|
||||
struct PropsC<'src> {
|
||||
val: &'src str
|
||||
}
|
||||
|
||||
fn CustomC<'a>(ctx: Context<'a>, props: &'a PropsC<'a>) -> DomTree {
|
||||
ctx.render(rsx!{
|
||||
div {
|
||||
"CustomC {props.val}"
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,8 @@ fn main() {
|
||||
console_error_panic_hook::set_once();
|
||||
|
||||
wasm_bindgen_futures::spawn_local(async {
|
||||
WebsysRenderer::new_with_props(Example, ExampleProps { initial_name: "..?", blarg: Vec::new()})
|
||||
let props = ExampleProps { initial_name: "..?", blarg: vec!["abc".to_string(), "abc".to_string()]};
|
||||
WebsysRenderer::new_with_props(Example, props)
|
||||
.run()
|
||||
.await
|
||||
.unwrap()
|
||||
@@ -38,17 +39,19 @@ static Example: FC<ExampleProps> = |ctx, props| {
|
||||
"Hello, {name}"
|
||||
}
|
||||
|
||||
CustomButton { name: sub, set_name: Box::new(move || set_name("jack")) }
|
||||
// CustomButton { name: "Jack!", set_name: Box::new(move || set_name("jack")) }
|
||||
// CustomButton { name: "Jill!", set_name: Box::new(move || set_name("jill")) }
|
||||
// CustomButton { name: "Reset!", set_name: Box::new(move || set_name(props.initial_name)) }
|
||||
// CustomButton { name: sub, set_name: Box::new(move || set_name("jack")) }
|
||||
CustomButton { name: "Jack!", set_name: Box::new(move || set_name("jack")) }
|
||||
CustomButton { name: "Jill!", set_name: Box::new(move || set_name("jill")) }
|
||||
CustomButton { name: "Bill!", set_name: Box::new(move || set_name("Bill")) }
|
||||
CustomButton { name: "Reset!", set_name: Box::new(move || set_name(props.initial_name)) }
|
||||
|
||||
}
|
||||
})
|
||||
};
|
||||
|
||||
#[derive(Props)]
|
||||
struct ButtonProps<'src> {
|
||||
name: &'src String,
|
||||
name: &'src str,
|
||||
// name: &'src str,
|
||||
set_name: Box< dyn Fn() + 'src>
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user