Skip to content

Commit

Permalink
Add #[component] to components that don't have it
Browse files Browse the repository at this point in the history
  • Loading branch information
Leonard committed Sep 14, 2023
1 parent 9b3442c commit 7d87290
Show file tree
Hide file tree
Showing 17 changed files with 34 additions and 26 deletions.
4 changes: 3 additions & 1 deletion docs-src/0.4/en/reference/use_coroutine.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ We can combine coroutines with [Fermi](https://docs.rs/fermi/latest/fermi/index.
```rust, no_run
static USERNAME: Atom<String> = Atom(|_| "default".to_string());
fn app(cx: Scope) -> Element {
#[component]
fn App(cx: Scope) -> Element {
let atoms = use_atom_root(cx);
use_coroutine(cx, |rx| sync_service(rx, atoms.clone()));
Expand All @@ -155,6 +156,7 @@ fn app(cx: Scope) -> Element {
})
}
#[component]
fn Banner(cx: Scope) -> Element {
let username = use_read(cx, &USERNAME);
Expand Down
2 changes: 1 addition & 1 deletion examples/prerender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
//! cargo run --features ssr --example prerender
//! ```
#![allow(non_snake_case, unused)]
#![allow(unused)]
use dioxus::prelude::*;
use dioxus_docs_site::*;
use dioxus_fullstack::{launch, prelude::*};
Expand Down
2 changes: 2 additions & 0 deletions src/components/homepage/hero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ pub fn Hero(cx: Scope) -> Element {

static ADD_TO_CLIPBOARD: &str = r#"navigator.clipboard.writeText("cargo add dioxus")"#;

#[component]
fn SaveClipboard(cx: Scope) -> Element {
let saved = use_state(cx, || false);

Expand All @@ -79,6 +80,7 @@ fn SaveClipboard(cx: Scope) -> Element {
})
}

#[component]
fn AnimatedIcon(cx: Scope) -> Element {
let dark = include_str!("../../../public/static/multiplatform-dark.svg");
let light = include_str!("../../../public/static/multiplatform-light.svg");
Expand Down
2 changes: 1 addition & 1 deletion src/doc_examples/event_nested.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;

fn main() {
dioxus_desktop::launch(App);
}

#[component]
fn App(cx: Scope) -> Element {
// ANCHOR: rsx
cx.render(rsx! {
Expand Down
2 changes: 1 addition & 1 deletion src/doc_examples/event_prevent_default.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;

#[component]
pub fn App(cx: Scope) -> Element {
// ANCHOR: prevent_default
cx.render(rsx! {
Expand Down
1 change: 0 additions & 1 deletion src/doc_examples/hackernews_state.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;

pub mod app_v1 {
Expand Down
3 changes: 1 addition & 2 deletions src/doc_examples/hello_world.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#![allow(non_snake_case)]

use dioxus::prelude::*;

#[component]
pub fn HelloWorldCounter(cx: Scope) -> Element {
cx.render(rsx! {
div {
Expand Down
2 changes: 0 additions & 2 deletions src/doc_examples/hello_world_ssr.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#![allow(unused)]
#![allow(non_snake_case)]
// ANCHOR: all

// ANCHOR: main
#![allow(non_snake_case)]
use axum::{response::Html, routing::get, Router};
// import the prelude to get access to the `rsx!` macro and the `Scope` and `Element` types
use dioxus::prelude::*;
Expand Down
2 changes: 1 addition & 1 deletion src/doc_examples/hooks_counter_two_state.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;

// ANCHOR: component
#[component]
pub fn App(cx: Scope) -> Element {
// ANCHOR: use_state_calls
let mut count_a = use_state(cx, || 0);
Expand Down
9 changes: 5 additions & 4 deletions src/doc_examples/hydration.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#![allow(non_snake_case, unused)]
#![allow(unused)]
use dioxus::prelude::*;

fn main() {
#[cfg(feature = "web")]
dioxus_web::launch_cfg(app, dioxus_web::Config::new().hydrate(true));
dioxus_web::launch_cfg(App, dioxus_web::Config::new().hydrate(true));
#[cfg(feature = "ssr")]
{
use dioxus_fullstack::prelude::*;
Expand All @@ -14,7 +14,7 @@ fn main() {
axum::Server::bind(&addr)
.serve(
axum::Router::new()
.serve_dioxus_application("", ServeConfigBuilder::new(app, ()))
.serve_dioxus_application("", ServeConfigBuilder::new(App, ()))
.into_make_service(),
)
.await
Expand All @@ -23,7 +23,8 @@ fn main() {
}
}

fn app(cx: Scope) -> Element {
#[component]
fn App(cx: Scope) -> Element {
let mut count = use_state(cx, || 0);

cx.render(rsx! {
Expand Down
2 changes: 1 addition & 1 deletion src/doc_examples/input_controlled.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;

// ANCHOR: component
#[component]
pub fn App(cx: Scope) -> Element {
let name = use_state(cx, || "bob".to_string());

Expand Down
2 changes: 1 addition & 1 deletion src/doc_examples/input_fileengine_async.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(non_snake_case)]
use dioxus::prelude::*;

// ANCHOR: component
#[component]
pub fn App(cx: Scope) -> Element {
let files_uploaded: &UseRef<Vec<String>> = use_ref(cx, Vec::new);

Expand Down
5 changes: 3 additions & 2 deletions src/doc_examples/readme_expanded.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
use dioxus::prelude::*;

fn main() {
dioxus_desktop::launch(app);
dioxus_desktop::launch(App);
}

fn app(cx: Scope) -> Element {
#[component]
fn App(cx: Scope) -> Element {
let mut count = use_state(cx, || 0);

cx.render(
Expand Down
7 changes: 4 additions & 3 deletions src/doc_examples/server_data_fetch.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#![allow(non_snake_case, unused)]
#![allow(unused)]

use dioxus::prelude::*;
use dioxus_fullstack::prelude::*;

fn main() {
LaunchBuilder::new(app).launch();
LaunchBuilder::new(App).launch();
}

fn app(cx: Scope) -> Element {
#[component]
fn App(cx: Scope) -> Element {
let mut count = use_future(cx, (), |_| async { get_server_data().await });

cx.render(rsx! {
Expand Down
7 changes: 4 additions & 3 deletions src/doc_examples/server_data_prefetch.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#![allow(non_snake_case, unused)]
#![allow(unused)]

use dioxus::prelude::*;
use dioxus_fullstack::prelude::*;

fn main() {
LaunchBuilder::new(app).launch();
LaunchBuilder::new(App).launch();
}

fn app(cx: Scope) -> Element {
#[component]
fn App(cx: Scope) -> Element {
let mut count = use_server_future(cx, (), |_| async { get_server_data().await })?;

cx.render(rsx! {
Expand Down
5 changes: 4 additions & 1 deletion src/doc_examples/spawn.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#![allow(non_snake_case, unused)]
#![allow(unused)]

use dioxus::prelude::*;

#[component]
pub fn App(cx: Scope) -> Element {
// ANCHOR: spawn
let logged_in = use_state(cx, || false);
Expand Down Expand Up @@ -41,6 +42,7 @@ pub fn App(cx: Scope) -> Element {
}

#[cfg(feature = "doc_test")]
#[component]
pub fn Tokio(cx: Scope) -> Element {
let _ = || {
// ANCHOR: tokio
Expand All @@ -58,6 +60,7 @@ pub fn Tokio(cx: Scope) -> Element {
cx.render(rsx!(()))
}

#[component]
pub fn ToOwnedMacro(cx: Scope) -> Element {
let count = use_state(cx, || 0);
let age = use_state(cx, || 0);
Expand Down
3 changes: 2 additions & 1 deletion src/doc_examples/use_coroutine.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#![allow(non_snake_case, unused)]
#![allow(unused)]
use dioxus::prelude::*;
use std::collections::HashMap;

#[component]
pub fn App(cx: Scope) -> Element {
// ANCHOR: use_coroutine
// import futures::StreamExt to use the next() method
Expand Down

0 comments on commit 7d87290

Please sign in to comment.