2021-07-02 05:30:52 +00:00
|
|
|
use dioxus::prelude::*;
|
|
|
|
fn main() {}
|
|
|
|
|
2021-10-16 21:37:28 +00:00
|
|
|
pub static Example: FC<()> = |(cx, props)| {
|
2021-07-02 05:30:52 +00:00
|
|
|
cx.render(rsx! {
|
|
|
|
div {
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
2021-07-16 20:11:25 +00:00
|
|
|
|
|
|
|
// A controlled component:
|
2021-10-16 21:37:28 +00:00
|
|
|
static ControlledSelect: FC<()> = |(cx, props)| {
|
2021-07-16 20:11:25 +00:00
|
|
|
let value = use_state(cx, || String::from("Grapefruit"));
|
|
|
|
cx.render(rsx! {
|
|
|
|
select { value: "{value}", onchange: move |evt| value.set(evt.value()),
|
|
|
|
option { value: "Grapefruit", "Grapefruit"}
|
|
|
|
option { value: "Lime", "Lime"}
|
|
|
|
option { value: "Coconut", "Coconut"}
|
|
|
|
option { value: "Mango", "Mango"}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
// TODO - how do uncontrolled things work?
|
2021-10-16 21:37:28 +00:00
|
|
|
static UncontrolledSelect: FC<()> = |(cx, props)| {
|
2021-07-16 20:11:25 +00:00
|
|
|
let value = use_state(cx, || String::new());
|
|
|
|
|
|
|
|
cx.render(rsx! {
|
|
|
|
select {
|
|
|
|
option { value: "Grapefruit", "Grapefruit"}
|
|
|
|
option { value: "Lime", "Lime"}
|
|
|
|
option { value: "Coconut", "Coconut"}
|
|
|
|
option { value: "Mango", "Mango"}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
};
|