31 lines
584 B
Rust
31 lines
584 B
Rust
use yew::prelude::*;
|
|
|
|
#[component(Home)]
|
|
pub fn home_component() -> Html {
|
|
let counter = use_state(|| 0);
|
|
let onclick = {
|
|
let counter = counter.clone();
|
|
move |_| {
|
|
let value = *counter + 1;
|
|
counter.set(value);
|
|
}
|
|
};
|
|
|
|
html! {
|
|
<div>
|
|
<button {onclick}>{ "+1" }</button>
|
|
<p>{ *counter }</p>
|
|
</div>
|
|
}
|
|
}
|
|
|
|
#[component(NotFound)]
|
|
pub fn not_found_component() -> Html {
|
|
let message = "404 Not found";
|
|
html! {
|
|
<div>
|
|
<h1>{&message}</h1>
|
|
</div>
|
|
}
|
|
}
|