mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
Pass string types to Html props (#2872)
* Pass string types to Html props * Not sure why passing None explicitly here... * Update test stderr
This commit is contained in:
parent
9556266061
commit
bff497e002
@ -6,5 +6,5 @@ This is an example that demonstrates `<Suspense />` support.
|
||||
|
||||
## Concepts
|
||||
|
||||
This example shows that how `<Suspense />` works in Yew and how you can
|
||||
This example shows how `<Suspense />` works in Yew and how you can
|
||||
create hooks that utilises suspense.
|
||||
|
||||
@ -375,4 +375,46 @@ fn compile_pass() {
|
||||
::yew::html_nested! { 1 };
|
||||
}
|
||||
|
||||
#[derive(
|
||||
::std::clone::Clone, ::yew::Properties, ::std::default::Default, ::std::cmp::PartialEq,
|
||||
)]
|
||||
pub struct HtmlPassedAsPropProperties {
|
||||
pub value: ::yew::Html,
|
||||
}
|
||||
|
||||
pub struct HtmlPassedAsProp;
|
||||
impl ::yew::Component for HtmlPassedAsProp {
|
||||
type Message = ();
|
||||
type Properties = HtmlPassedAsPropProperties;
|
||||
|
||||
fn create(_ctx: &::yew::Context<Self>) -> Self {
|
||||
::std::unimplemented!()
|
||||
}
|
||||
|
||||
fn view(&self, _ctx: &::yew::Context<Self>) -> ::yew::Html {
|
||||
::std::unimplemented!()
|
||||
}
|
||||
}
|
||||
|
||||
pub struct HtmlPassedAsPropContainer;
|
||||
impl ::yew::Component for HtmlPassedAsPropContainer {
|
||||
type Message = ();
|
||||
type Properties = ();
|
||||
|
||||
fn create(_ctx: &::yew::Context<Self>) -> Self {
|
||||
::std::unimplemented!()
|
||||
}
|
||||
|
||||
fn view(&self, _ctx: &::yew::Context<Self>) -> ::yew::Html {
|
||||
::yew::html! {
|
||||
<>
|
||||
<HtmlPassedAsProp value={::yew::html!()} />
|
||||
<HtmlPassedAsProp value="string literal" />
|
||||
<HtmlPassedAsProp value={::std::format!("string")} />
|
||||
<HtmlPassedAsProp value={::yew::AttrValue::Static("attr value")} />
|
||||
</>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
||||
@ -480,10 +480,10 @@ error[E0277]: the trait bound `Option<NotToString>: IntoPropValue<Option<implici
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<Option<&'static str> as IntoPropValue<Option<String>>>
|
||||
<Option<&'static str> as IntoPropValue<Option<VNode>>>
|
||||
<Option<&'static str> as IntoPropValue<Option<implicit_clone::unsync::IString>>>
|
||||
<Option<F> as IntoPropValue<Option<yew::Callback<I, O>>>>
|
||||
<Option<Rc<str>> as IntoPropValue<Option<implicit_clone::unsync::IString>>>
|
||||
and 4 others
|
||||
and 7 others
|
||||
|
||||
error[E0277]: the trait bound `Option<{integer}>: IntoPropValue<Option<implicit_clone::unsync::IString>>` is not satisfied
|
||||
--> tests/html_macro/element-fail.rs:48:22
|
||||
@ -496,10 +496,10 @@ error[E0277]: the trait bound `Option<{integer}>: IntoPropValue<Option<implicit_
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<Option<&'static str> as IntoPropValue<Option<String>>>
|
||||
<Option<&'static str> as IntoPropValue<Option<VNode>>>
|
||||
<Option<&'static str> as IntoPropValue<Option<implicit_clone::unsync::IString>>>
|
||||
<Option<F> as IntoPropValue<Option<yew::Callback<I, O>>>>
|
||||
<Option<Rc<str>> as IntoPropValue<Option<implicit_clone::unsync::IString>>>
|
||||
and 4 others
|
||||
and 7 others
|
||||
|
||||
error[E0277]: expected a `Fn<(MouseEvent,)>` closure, found `{integer}`
|
||||
--> tests/html_macro/element-fail.rs:51:28
|
||||
@ -594,10 +594,10 @@ error[E0277]: the trait bound `Option<yew::NodeRef>: IntoPropValue<yew::NodeRef>
|
||||
|
|
||||
= help: the following implementations were found:
|
||||
<Option<&'static str> as IntoPropValue<Option<String>>>
|
||||
<Option<&'static str> as IntoPropValue<Option<VNode>>>
|
||||
<Option<&'static str> as IntoPropValue<Option<implicit_clone::unsync::IString>>>
|
||||
<Option<F> as IntoPropValue<Option<yew::Callback<I, O>>>>
|
||||
<Option<Rc<str>> as IntoPropValue<Option<implicit_clone::unsync::IString>>>
|
||||
and 4 others
|
||||
and 7 others
|
||||
|
||||
error[E0277]: expected a `Fn<(MouseEvent,)>` closure, found `yew::Callback<String>`
|
||||
--> tests/html_macro/element-fail.rs:58:29
|
||||
|
||||
@ -176,6 +176,9 @@ impl_into_prop!(|value: &'static str| -> AttrValue { AttrValue::Static(value) })
|
||||
impl_into_prop!(|value: String| -> AttrValue { AttrValue::Rc(Rc::from(value)) });
|
||||
impl_into_prop!(|value: Rc<str>| -> AttrValue { AttrValue::Rc(value) });
|
||||
impl_into_prop!(|value: VNode| -> Children { Children::new(vec![value]) });
|
||||
impl_into_prop!(|value: &'static str| -> VNode { crate::html!(value) });
|
||||
impl_into_prop!(|value: String| -> VNode { crate::html!(value) });
|
||||
impl_into_prop!(|value: AttrValue| -> VNode { crate::html!(value) });
|
||||
|
||||
impl<T: ImplicitClone + 'static> IntoPropValue<IArray<T>> for &'static [T] {
|
||||
fn into_prop_value(self) -> IArray<T> {
|
||||
|
||||
@ -151,7 +151,7 @@ mod feat_csr_ssr {
|
||||
let SuspenseProps { children, fallback } = props.clone();
|
||||
|
||||
let fallback = html! {
|
||||
<BaseSuspense fallback={None}>
|
||||
<BaseSuspense>
|
||||
{fallback}
|
||||
</BaseSuspense>
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user