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