docs: fix lifetimes on children
This commit is contained in:
1 parent
f130e662be
commit
0596088312
1 file changed
+5
-5
@@ -30,7 +30,7 @@ struct ClickableProps<'a> {
|
|||||||
title: &'a str
|
title: &'a str
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Clickable(cx: Scope<ClickableProps>) -> Element {
|
fn Clickable<'a>(cx: Scope<'a, ClickableProps>) -> Element {
|
||||||
cx.render(rsx!(
|
cx.render(rsx!(
|
||||||
a {
|
a {
|
||||||
href: "{cx.props.href}"
|
href: "{cx.props.href}"
|
||||||
@@ -64,7 +64,7 @@ struct ClickableProps<'a> {
|
|||||||
body: Element<'a>
|
body: Element<'a>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Clickable(cx: Scope<ClickableProps>) -> Element {
|
fn Clickable<'a>(cx: Scope<'a, ClickableProps<'a>>) -> Element {
|
||||||
cx.render(rsx!(
|
cx.render(rsx!(
|
||||||
a {
|
a {
|
||||||
href: "{cx.props.href}",
|
href: "{cx.props.href}",
|
||||||
@@ -98,7 +98,7 @@ struct ClickableProps<'a> {
|
|||||||
children: Element<'a>
|
children: Element<'a>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Clickable(cx: Scope<ClickableProps>) -> Element {
|
fn Clickable<'a>(cx: Scope<'a, ClickableProps>) -> Element {
|
||||||
cx.render(rsx!(
|
cx.render(rsx!(
|
||||||
a {
|
a {
|
||||||
href: "{cx.props.href}",
|
href: "{cx.props.href}",
|
||||||
@@ -125,7 +125,7 @@ While technically allowed, it's an antipattern to pass children more than once i
|
|||||||
However, because the `Element` is transparently a `VNode`, we can actually match on it to extract the nodes themselves, in case we are expecting a specific format:
|
However, because the `Element` is transparently a `VNode`, we can actually match on it to extract the nodes themselves, in case we are expecting a specific format:
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
fn clickable(cx: Scope<ClickableProps>) -> Element {
|
fn clickable<'a>(cx: Scope<'a, ClickableProps>) -> Element {
|
||||||
match cx.props.children {
|
match cx.props.children {
|
||||||
Some(VNode::Text(text)) => {
|
Some(VNode::Text(text)) => {
|
||||||
// ...
|
// ...
|
||||||
@@ -184,7 +184,7 @@ struct ClickableProps<'a> {
|
|||||||
onclick: EventHandler<'a, MouseEvent>
|
onclick: EventHandler<'a, MouseEvent>
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clickable(cx: Scope<ClickableProps>) -> Element {
|
fn clickable<'a>(cx: Scope<'a, ClickableProps>) -> Element {
|
||||||
cx.render(rsx!(
|
cx.render(rsx!(
|
||||||
a {
|
a {
|
||||||
onclick: move |evt| cx.props.onclick.call(evt)
|
onclick: move |evt| cx.props.onclick.call(evt)
|
||||||
|
|||||||
Reference in new issue
Block a user