pub struct NodeRef<T>(_)
where
T: Clone + 'static;
Expand description
Contains a shared reference to a DOM node creating while using the view
macro to create your UI.
#[component]
pub fn MyComponent(cx: Scope) -> impl IntoView {
let input_ref = NodeRef::<HtmlElement<Input>>::new(cx);
let on_click = move |_| {
let node = input_ref
.get()
.expect("input_ref should be loaded by now");
log!("value is {:?}", node.value())
};
view! {
cx,
<div>
<input _ref=input_ref type="text"/>
<button on:click=on_click>"Click me"</button>
</div>
}
}
Creates an empty reference.
Gets the element that is currently stored in the reference.
This tracks reactively, so that node references can be used in effects.
Initially, the value will be None
, but once it is loaded the effect
will rerun and its value will be Some(Element)
.
Performs copy-assignment from
source
.
Read more
🔬This is a nightly-only experimental API. (fn_traits
)
Performs the call operation.
🔬This is a nightly-only experimental API. (fn_traits
)
Performs the call operation.
The returned type after the call operator is used.
🔬This is a nightly-only experimental API. (fn_traits
)
Performs the call operation.
This method tests for self
and other
values to be equal, and is used
by ==
.
This method tests for !=
. The default implementation is almost always
sufficient, and should not be overridden without very good reason.
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Instruments this type with the provided
Span
, returning an
Instrumented
wrapper.
Read more
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
Converts the value into
View
.
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning.
Read more
Uses borrowed data to replace owned data, usually by cloning.
Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.