Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/yew-agent/src/oneshot/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ where
/// The Oneshot Agent Provider.
///
/// This component provides its children access to an oneshot agent.
#[function_component]
#[component]
pub fn OneshotProvider<T, C = Bincode>(props: &WorkerProviderProps) -> Html
where
T: Oneshot + 'static,
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-agent/src/reactor/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ where
/// The Reactor Agent Provider.
///
/// This component provides its children access to a reactor agent.
#[function_component]
#[component]
pub fn ReactorProvider<R, C = Bincode>(props: &WorkerProviderProps) -> Html
where
R: 'static + Reactor,
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-agent/src/worker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
//! # }
//! # }
//! use my_worker_mod::MyWorker; // note that <MyWorker as yew_agent::Worker>::Output == WorkerResponseType
//! #[function_component(UseWorkerBridge)]
//! #[component(UseWorkerBridge)]
//! fn bridge() -> Html {
//! let counter = use_state(|| 0);
//!
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-agent/src/worker/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ where
/// The Worker Agent Provider.
///
/// This component provides its children access to a worker agent.
#[function_component]
#[component]
pub fn WorkerProvider<W, C = Bincode>(props: &WorkerProviderProps) -> Html
where
W: Worker + 'static,
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-macro/src/function_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Parse for FunctionComponent {
item => {
return Err(syn::Error::new_spanned(
item,
"`function_component` attribute can only be applied to functions",
"`component` attribute can only be applied to functions",
))
}
};
Expand Down
4 changes: 2 additions & 2 deletions packages/yew-macro/tests/derive_props/pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,12 +258,12 @@ mod value_into_some_value_in_props {
optional: ::std::option::Option<usize>
}

#[::yew::function_component]
#[::yew::component]
fn Inner(_props: &Props) -> ::yew::html::Html {
::yew::html!{}
}

#[::yew::function_component]
#[::yew::component]
fn Main() -> ::yew::html::Html {
::yew::html! {<>
<Inner required=3 optional=5/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(Comp)]
#[component(Comp)]
struct Test;

fn main() {}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
error: `function_component` attribute can only be applied to functions
error: `component` attribute can only be applied to functions
--> $DIR/applied-to-non-fn-fail.rs:9:1
|
9 | struct Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(Comp)]
#[component(Comp)]
async fn comp(props: &Props) -> Html {
html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(let)]
#[component(let)]
fn comp(props: &Props) -> Html {
html! {
<p>
Expand All @@ -14,7 +14,7 @@ fn comp(props: &Props) -> Html {
}
}

#[function_component(x, y, z)]
#[component(x, y, z)]
fn comp_2(props: &Props) -> Html {
html! {
<p>
Expand All @@ -23,7 +23,7 @@ fn comp_2(props: &Props) -> Html {
}
}

#[function_component(124)]
#[component(124)]
fn comp_3(props: &Props) -> Html {
html! {
<p>
Expand All @@ -32,7 +32,7 @@ fn comp_3(props: &Props) -> Html {
}
}

#[function_component(component)]
#[component(component)]
fn component(props: &Props) -> Html {
html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
error: expected identifier, found keyword `let`
--> tests/function_component_attr/bad-name-fail.rs:8:22
--> tests/function_component_attr/bad-name-fail.rs:8:13
|
8 | #[function_component(let)]
| ^^^
8 | #[component(let)]
| ^^^

error: unexpected token
--> tests/function_component_attr/bad-name-fail.rs:17:23
--> tests/function_component_attr/bad-name-fail.rs:17:14
|
17 | #[function_component(x, y, z)]
| ^
17 | #[component(x, y, z)]
| ^

error: expected identifier
--> tests/function_component_attr/bad-name-fail.rs:26:22
--> tests/function_component_attr/bad-name-fail.rs:26:13
|
26 | #[function_component(124)]
| ^^^
26 | #[component(124)]
| ^^^

error: the component must not have the same name as the function
--> tests/function_component_attr/bad-name-fail.rs:35:22
--> tests/function_component_attr/bad-name-fail.rs:35:13
|
35 | #[function_component(component)]
| ^^^^^^^^^
35 | #[component(component)]
| ^^^^^^^^^
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(Comp)]
#[component(Comp)]
fn comp(props: Props) -> Html {
html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ struct Props {
a: usize,
}

#[function_component(Comp1)]
#[component(Comp1)]
fn comp_1(_props: &Props) {}

#[function_component(Comp)]
#[component(Comp)]
fn comp(_props: &Props) -> u32 {
1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ error: function components must return `yew::Html` or `yew::HtmlResult`
error[E0277]: the trait bound `u32: IntoHtmlResult` is not satisfied
--> tests/function_component_attr/bad-return-type-fail.rs:11:1
|
11 | #[function_component(Comp)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoHtmlResult` is not implemented for `u32`
11 | #[component(Comp)]
| ^^^^^^^^^^^^^^^^^^ the trait `IntoHtmlResult` is not implemented for `u32`
|
= help: the following other types implement trait `IntoHtmlResult`:
VNode
Result<VNode, RenderError>
= note: this error originates in the attribute macro `function_component` (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the attribute macro `component` (in Nightly builds, run with -Z macro-backtrace for more info)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(Comp)]
#[component(Comp)]
const fn comp(props: &Props) -> Html {
html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(Comp)]
#[component(Comp)]
extern "C" fn comp(props: &Props) -> Html {
html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(Comp)]
#[component(Comp)]
fn comp<'a>(props: &'a Props) -> Html {
html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ struct Props {
a: ::std::primitive::usize,
}

#[::yew::function_component(Comp)]
#[::yew::component(Comp)]
fn comp<P>(_props: &P) -> ::yew::Html
where
P: ::yew::Properties + ::std::cmp::PartialEq,
Expand All @@ -50,14 +50,14 @@ where
}
}

#[::yew::function_component(Comp1)]
#[::yew::component(Comp1)]
fn comp1<T1, T2>(_props: &()) -> ::yew::Html {
::yew::html! {
<p></p>
}
}

#[::yew::function_component(ConstGenerics)]
#[::yew::component(ConstGenerics)]
fn const_generics<const N: ::std::primitive::i32>() -> ::yew::Html {
::yew::html! {
<div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(Comp)]
#[component(Comp)]
fn comp<P>(_props: &P) -> Html
where
P: Properties + PartialEq,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ error[E0277]: the trait bound `MissingTypeBounds: yew::Properties` is not satisf
note: required by a bound in `Comp`
--> tests/function_component_attr/generic-props-fail.rs:11:8
|
8 | #[function_component(Comp)]
| ---- required by a bound in this struct
8 | #[component(Comp)]
| ---- required by a bound in this struct
...
11 | P: Properties + PartialEq,
| ^^^^^^^^^^ required by this bound in `Comp`
Expand All @@ -65,8 +65,8 @@ note: required by a bound in `Comp`
error[E0599]: the function or associated item `new` exists for struct `VChild<Comp<MissingTypeBounds>>`, but its trait bounds were not satisfied
--> tests/function_component_attr/generic-props-fail.rs:27:14
|
8 | #[function_component(Comp)]
| ------------------------- doesn't satisfy `Comp<MissingTypeBounds>: yew::BaseComponent`
8 | #[component(Comp)]
| ---------------- doesn't satisfy `Comp<MissingTypeBounds>: yew::BaseComponent`
...
27 | html! { <Comp<MissingTypeBounds> /> };
| ^^^^ function or associated item cannot be called on `VChild<Comp<MissingTypeBounds>>` due to unsatisfied trait bounds
Expand Down Expand Up @@ -106,10 +106,10 @@ error[E0107]: missing generics for struct `Comp`
| ^^^^ expected 1 generic argument
|
note: struct defined here, with 1 generic parameter: `P`
--> tests/function_component_attr/generic-props-fail.rs:8:22
--> tests/function_component_attr/generic-props-fail.rs:8:13
|
8 | #[function_component(Comp)]
| ^^^^
8 | #[component(Comp)]
| ^^^^
9 | fn comp<P>(_props: &P) -> Html
| -
help: add missing generic argument
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use yew::prelude::*;
#[derive(Debug, PartialEq, Clone)]
struct Ctx;

#[function_component]
#[component]
fn Comp() -> Html {
if let Some(_m) = use_context::<Ctx>() {
use_context::<Ctx>().unwrap();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
)]
struct Ctx;

#[::yew::prelude::function_component]
#[::yew::prelude::component]
fn Comp() -> ::yew::prelude::Html {
::yew::prelude::use_context::<Ctx>().unwrap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(Comp)]
#[component(Comp)]
fn comp(props: &'static Props) -> Html {
html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(Comp)]
#[component(Comp)]
fn comp(props: &Props, invalid: String) -> Html {
html! {
<p>
Expand All @@ -15,7 +15,7 @@ fn comp(props: &Props, invalid: String) -> Html {
}
}

#[function_component(Comp)]
#[component(Comp)]
fn comp3(props: &Props, invalid: String, another_invalid: u32) -> Html {
html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ struct Props {
a: usize,
}

#[function_component(Comp)]
#[component(Comp)]
fn comp(props: &mut Props) -> Html {
html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ struct Props {
a: usize,
}

#[::yew::prelude::function_component]
#[::yew::prelude::component]
fn Comp(props: &Props) -> ::yew::prelude::Html {
::yew::prelude::html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ impl<A> ::std::cmp::PartialEq for CompProps<A> {
}
}

#[::yew::prelude::function_component(Comp)]
#[::yew::prelude::component(Comp)]
pub fn comp<A = ()>(_props: &CompProps<A>) -> ::yew::prelude::Html {
::std::todo!()
}

#[::yew::prelude::function_component(App)]
#[::yew::prelude::component(App)]
pub fn app() -> ::yew::prelude::Html {
::yew::prelude::html! { <Comp /> } // No generics here.
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct Props {
a: ::std::primitive::usize,
}

#[::yew::function_component(Comp)]
#[::yew::component(Comp)]
fn comp(props: &Props) -> ::yew::Html {
::yew::html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct Props {
struct Test;

impl Test {
#[function_component(Comp)]
#[component(Comp)]
fn comp(self, props: &Props) -> Html {
html! {
<p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ pub struct u8;
#[allow(non_camel_case_types)]
pub struct usize;

#[::yew::function_component(Comp)]
#[::yew::component(Comp)]
fn comp() -> ::yew::Html {
::yew::html! {
<p>
Expand Down
Loading
Loading