Struct yew::html::NodeRef [−][src]
pub struct NodeRef(_);
Expand description
Wrapped Node reference for later use in Component lifecycle methods.
Example
Focus an <input>
element on mount.
#[cfg(feature = "std_web")] use stdweb::web::{html_element::InputElement, IHtmlElement}; #[cfg(feature = "web_sys")] use web_sys::HtmlInputElement as InputElement; pub struct Input { node_ref: NodeRef, } impl Component for Input { type Message = (); type Properties = (); fn create(_: Self::Properties, _: ComponentLink<Self>) -> Self { Input { node_ref: NodeRef::default(), } } fn rendered(&mut self, first_render: bool) { if first_render { if let Some(input) = self.node_ref.cast::<InputElement>() { input.focus(); } } } fn change(&mut self, _: Self::Properties) -> ShouldRender { false } fn update(&mut self, _: Self::Message) -> ShouldRender { false } fn view(&self) -> Html { html! { <input ref=self.node_ref.clone() type="text" /> } } }
Relevant examples
Implementations
Trait Implementations
impl ImplicitClone for NodeRef
[src]
Auto Trait Implementations
impl !RefUnwindSafe for NodeRef
impl !Send for NodeRef
impl !Sync for NodeRef
impl Unpin for NodeRef
impl !UnwindSafe for NodeRef
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<T> Any for T where
T: Any,
[src]
T: Any,
impl<T> CloneAny for T where
T: Any + Clone,
[src]
T: Any + Clone,