Simple NodeRef passing to <Link> for yew-router (#2877)

* simple NodeRef passing

* using `anchor_ref` opposed to `a_ref` per @futursolo's review
This commit is contained in:
Athan Clark 2022-09-18 21:05:23 -04:00 committed by GitHub
parent ce70e4c1fb
commit 89dd3b3e7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -24,6 +24,9 @@ where
pub query: Option<Q>, pub query: Option<Q>,
#[prop_or_default] #[prop_or_default]
pub disabled: bool, pub disabled: bool,
/// [`NodeRef`](yew::html::NodeRef) for the `<a>` element.
#[prop_or_default]
pub anchor_ref: NodeRef,
#[prop_or_default] #[prop_or_default]
pub children: Children, pub children: Children,
} }
@ -41,6 +44,7 @@ where
children, children,
disabled, disabled,
query, query,
anchor_ref,
} = props.clone(); } = props.clone();
let navigator = use_navigator().expect_throw("failed to get navigator"); let navigator = use_navigator().expect_throw("failed to get navigator");
@ -86,6 +90,7 @@ where
{href} {href}
{onclick} {onclick}
{disabled} {disabled}
ref={anchor_ref}
> >
{ children } { children }
</a> </a>