Minor Bugfixes

This commit is contained in:
2026-04-28 20:42:18 +02:00
parent ce86d8bc8f
commit dac2d91213
7 changed files with 111 additions and 20 deletions

View File

@@ -1,20 +1,29 @@
mod pages;
use crate::pages::*;
use yew::prelude::*;
use yew_router::prelude::*;
#[function_component]
pub fn App() -> Html {
let counter = use_state(|| 0);
let onclick = {
let counter = counter.clone();
move |_| {
let value = *counter + 1;
counter.set(value);
}
};
#[derive(Clone, PartialEq, Routable)]
enum Route {
#[at("/")]
Home,
#[not_found]
#[at("/404")]
NotFound,
}
html! {
<div>
<button {onclick}>{ "+1" }</button>
<p>{ *counter }</p>
</div>
fn switch(route: Route) -> Html {
match route {
Route::Home => html! { <basic_pages::Home/>},
Route::NotFound => html! { <basic_pages::Home/> },
}
}
#[component(App)]
pub fn app() -> Html {
html! {
<BrowserRouter>
<Switch<Route> render={switch} />
</BrowserRouter>
}
}