Skip to content

Commit 57a1278

Browse files
dedup function component names
1 parent 3e9c1f4 commit 57a1278

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

website/docs/tutorial/index.mdx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ in the `dev-dependencies` instead.
9090
```rust ,no_run title="src/main.rs"
9191
use yew::prelude::*;
9292

93-
#[function_component(App)]
94-
fn app() -> Html {
93+
#[function_component]
94+
fn App() -> Html {
9595
html! {
9696
<h1>{ "Hello World" }</h1>
9797
}
@@ -186,8 +186,8 @@ Now, let's convert this HTML into `html!`. Type (or copy/paste) the following sn
186186
such that the value of `html!` is returned by the function
187187

188188
```rust {3-21}
189-
#[function_component(App)]
190-
fn app() -> Html {
189+
#[function_component]
190+
fn App() -> Html {
191191
- html! {
192192
- <h1>{ "Hello World" }</h1>
193193
- }
@@ -233,8 +233,8 @@ struct Video {
233233
Next, we will create instances of this struct in our `app` function and use those instead of hardcoding the data:
234234

235235
```rust {3-29}
236-
#[function_component(App)]
237-
fn app() -> Html {
236+
#[function_component]
237+
fn App() -> Html {
238238
+ let videos = vec![
239239
+ Video {
240240
+ id: 1,
@@ -313,8 +313,8 @@ struct VideosListProps {
313313
videos: Vec<Video>,
314314
}
315315

316-
#[function_component(VideosList)]
317-
fn videos_list(VideosListProps { videos }: &VideosListProps) -> Html {
316+
#[function_component]
317+
fn VideosList(VideosListProps { videos }: &VideosListProps) -> Html {
318318
html! {
319319
for video in videos {
320320
<p key={video.id}>{format!("{}: {}", video.speaker, video.title)}</p>
@@ -334,8 +334,8 @@ The struct used for props must implement `Properties` by deriving it.
334334
Now, we can update our `App` component to make use of `VideosList` component.
335335

336336
```rust {9-12}
337-
#[function_component(App)]
338-
fn app() -> Html {
337+
#[function_component]
338+
fn App() -> Html {
339339
// ...
340340
html! {
341341
<>
@@ -374,9 +374,9 @@ struct VideosListProps {
374374
Then we modify the `VideosList` component to "emit" the selected video to the callback.
375375

376376
```rust {2-18}
377-
#[function_component(VideosList)]
378-
-fn videos_list(VideosListProps { videos }: &VideosListProps) -> Html {
379-
+fn videos_list(VideosListProps { videos, on_click }: &VideosListProps) -> Html {
377+
#[function_component]
378+
-fn VideosList(VideosListProps { videos }: &VideosListProps) -> Html {
379+
+fn VideosList(VideosListProps { videos, on_click }: &VideosListProps) -> Html {
380380
+ let on_select = |video: &Video| {
381381
+ let on_click = on_click.clone();
382382
+ let video = video.clone();
@@ -403,8 +403,8 @@ struct VideosDetailsProps {
403403
video: Video,
404404
}
405405

406-
#[function_component(VideoDetails)]
407-
fn video_details(VideosDetailsProps { video }: &VideosDetailsProps) -> Html {
406+
#[function_component]
407+
fn VideoDetails(VideosDetailsProps { video }: &VideosDetailsProps) -> Html {
408408
html! {
409409
<div>
410410
<h3>{ video.title.clone() }</h3>
@@ -512,8 +512,8 @@ Now as the last step, we need to update our `App` component to make the fetch re
512512
use yew::prelude::*;
513513
+use gloo_net::http::Request;
514514

515-
#[function_component(App)]
516-
fn app() -> Html {
515+
#[function_component]
516+
fn App() -> Html {
517517
- let videos = vec![
518518
- Video {
519519
- id: 1,

0 commit comments

Comments
 (0)