First
This commit is contained in:
commit
4b7cb4ad1e
9 changed files with 1756 additions and 0 deletions
29
src/front/components/hello.rs
Normal file
29
src/front/components/hello.rs
Normal file
|
@ -0,0 +1,29 @@
|
|||
use yew::prelude::*;
|
||||
|
||||
#[derive(Properties, PartialEq)]
|
||||
pub struct HelloProps {
|
||||
pub name: String,
|
||||
}
|
||||
|
||||
#[function_component]
|
||||
pub fn Hello(props: &HelloProps) -> Html {
|
||||
let counter = use_state(|| 0);
|
||||
let onclick = {
|
||||
let counter = counter.clone();
|
||||
Callback::from(move |_| counter.set(*counter + 1))
|
||||
};
|
||||
|
||||
|
||||
html! {
|
||||
<div>
|
||||
<button {onclick}>{ "Increment value" }</button>
|
||||
<p>
|
||||
<b>{ "Current value: " }</b>
|
||||
{ *counter }
|
||||
</p>
|
||||
<p>
|
||||
{ props.name.clone() }
|
||||
</p>
|
||||
</div>
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue