From 5f24fb95765300d8442379d0098c7fd27adab7b8 Mon Sep 17 00:00:00 2001 From: wiseaidev Date: Thu, 19 Oct 2023 11:15:20 +0300 Subject: [PATCH] bump wasm-bindgen, yew, rust, migrate from a struct based component to a functional component --- Cargo.toml | 11 ++++++----- LICENSE-MIT | 2 +- rustfmt.toml | 2 +- src/app.rs | 28 ++++------------------------ src/lib.rs | 6 ++---- 5 files changed, 14 insertions(+), 35 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8fa1d04..65aceab 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,21 +1,22 @@ [package] authors = [ "Kelly Thomas Kline ", - "Samuel Rounce " + "Samuel Rounce ", + "Mahmoud Harmouch " ] categories = ["gui", "wasm", "web-programming"] description = "yew-wasm-pack-minimal demonstrates the minimum code and tooling necessary for a frontend web app with simple deployable artifacts consisting of one HTML file, one JavaScript file, and one WebAssembly file, using Yew, wasm-bindgen, and wasm-pack." -edition = "2018" +edition = "2021" keywords = ["yew", "wasm", "wasm-bindgen", "web"] license = "MIT/Apache-2.0" name = "yew-wasm-pack-minimal" readme = "README.md" repository = "https://github.com/yewstack/yew-wasm-pack-minimal" -version = "0.1.0" +version = "0.1.1" [lib] crate-type = ["cdylib"] [dependencies] -wasm-bindgen = "^0.2" -yew = "0.17" +wasm-bindgen = "0.2.87" +yew = { version = "0.21.0", features = ["csr"] } diff --git a/LICENSE-MIT b/LICENSE-MIT index 9cfb930..97afd16 100644 --- a/LICENSE-MIT +++ b/LICENSE-MIT @@ -1,4 +1,4 @@ -Copyright (c) 2019 {{authors}} +Copyright (c) 2023 Yew Stack Core Team Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated diff --git a/rustfmt.toml b/rustfmt.toml index 32a9786..3a26366 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1 @@ -edition = "2018" +edition = "2021" diff --git a/src/app.rs b/src/app.rs index 8ac4863..db6909f 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1,28 +1,8 @@ use yew::prelude::*; -pub struct App {} - -pub enum Msg {} - -impl Component for App { - type Message = Msg; - type Properties = (); - - fn create(_: Self::Properties, _: ComponentLink) -> Self { - App {} - } - - fn update(&mut self, _msg: Self::Message) -> ShouldRender { - true - } - - fn change(&mut self, _: Self::Properties) -> ShouldRender { - false - } - - fn view(&self) -> Html { - html! { -

{ "Hello world!" }

- } +#[function_component(App)] +pub fn app() -> Html { + html! { +

{ "Hello world!" }

} } diff --git a/src/lib.rs b/src/lib.rs index 0c9c58d..fe437b0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,8 +3,6 @@ mod app; use wasm_bindgen::prelude::*; #[wasm_bindgen] -pub fn run_app() -> Result<(), JsValue> { - yew::start_app::(); - - Ok(()) +pub fn run_app() { + yew::Renderer::::new().render(); }