Skip to content

Commit 98b8d99

Browse files
committed
yew example
1 parent 0b37964 commit 98b8d99

File tree

3 files changed

+10
-31
lines changed

3 files changed

+10
-31
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
yew = "0.18"
9+
yew = { version = "0.20", features = ["csr"] }

index.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
<!DOCTYPE html>
2-
<html>
3-
<head>
4-
<meta charset="utf-8" />
5-
<title>Hello, World!</title>
6-
</head>
7-
</html>
2+
<html lang="en">
3+
<head> </head>
4+
<body></body>
5+
</html>

src/main.rs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,12 @@
11
use yew::prelude::*;
22

3-
struct Index;
4-
impl Component for Index {
5-
type Message = ();
6-
type Properties = ();
7-
8-
fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self {
9-
Self
10-
}
11-
12-
fn update(&mut self, _: Self::Message) -> ShouldRender {
13-
false
14-
}
15-
16-
fn change(&mut self, _: Self::Properties) -> ShouldRender {
17-
false
18-
}
19-
20-
fn view(&self) -> Html {
21-
html! {
22-
<div>
23-
{ "Hello, World!" }
24-
</div>
25-
}
3+
#[function_component(App)]
4+
fn app() -> Html {
5+
html! {
6+
<h1>{ "Hello World" }</h1>
267
}
278
}
289

2910
fn main() {
30-
yew::start_app::<Index>();
11+
yew::Renderer::<App>::new().render();
3112
}

0 commit comments

Comments
 (0)