Function use_js_ref

Source
pub fn use_js_ref<T: JsCast>(init: Option<T>) -> JsRefContainer<T>
Expand description

This hook can persist JS data through the entire lifetime of the component.

Use this if you need JS to set the ref value. If you only need to mutate the data from Rust, use use_ref() instead.

ยงExample

impl Component for MyComponent {
  fn render(&self) -> VNode {
    let input_element = use_js_ref(None);

    h!(div)
      .build(
        h!(input)
          .ref_container(&input_element)
          .html_type("text")
          .build(())
      )
  }
}