2021-02-24 08:51:26 +00:00
|
|
|
use builder::button;
|
2021-02-10 17:48:02 +00:00
|
|
|
use dioxus_core::prelude::*;
|
|
|
|
|
|
|
|
fn main() {}
|
|
|
|
struct SomeContext {
|
|
|
|
items: Vec<String>,
|
|
|
|
}
|
|
|
|
|
2021-02-12 04:03:01 +00:00
|
|
|
struct Props {
|
|
|
|
name: String,
|
|
|
|
}
|
2021-02-10 17:48:02 +00:00
|
|
|
|
2021-02-12 04:03:01 +00:00
|
|
|
#[allow(unused)]
|
|
|
|
static Example: FC<Props> = |ctx, props| {
|
|
|
|
let value = ctx.use_context(|c: &SomeContext| c.items.last().unwrap());
|
2021-02-10 17:48:02 +00:00
|
|
|
|
2021-02-12 04:03:01 +00:00
|
|
|
ctx.view(move |bump| {
|
2021-02-10 17:48:02 +00:00
|
|
|
button(bump)
|
2021-02-12 04:03:01 +00:00
|
|
|
.on("click", move |_| {
|
|
|
|
println!("Value is {}", props.name);
|
|
|
|
println!("Value is {}", value.as_str());
|
|
|
|
println!("Value is {}", *value);
|
|
|
|
})
|
|
|
|
.on("click", move |_| {
|
|
|
|
println!("Value is {}", props.name);
|
|
|
|
})
|
2021-02-10 17:48:02 +00:00
|
|
|
.finish()
|
|
|
|
})
|
|
|
|
// ctx.view(html! {
|
|
|
|
// <div>
|
|
|
|
// <button onclick={move |_| println!("Value is {}", value)} />
|
|
|
|
// <button onclick={move |_| println!("Value is {}", value)} />
|
|
|
|
// <button onclick={move |_| println!("Value is {}", value)} />
|
|
|
|
// <div>
|
|
|
|
// <p> "Value is: {val}" </p>
|
|
|
|
// </div>
|
|
|
|
// </div>
|
|
|
|
// })
|
|
|
|
};
|