react_sys/use_ref/
mod.rs

1use crate::macro_import::wasm_bindgen_react;
2use wasm_bindgen::prelude::*;
3
4mod macro_helpers;
5
6mod helpers;
7pub use helpers::*;
8
9wasm_bindgen_react! {
10    #[derive(Debug, Clone)]
11    pub type MutableRefObject;
12    #[wasm_bindgen(structural, method, getter)]
13    pub fn current(this: &MutableRefObject) -> JsValue;
14    #[wasm_bindgen(structural, method, setter)]
15    pub fn set_current(this: &MutableRefObject, val: JsValue);
16
17    #[wasm_bindgen(js_namespace = React, js_name = useRef)]
18    pub fn use_ref(initial_value: &JsValue) -> MutableRefObject;
19
20    /// Closure `get_initial_value` will be called immediately,
21    /// thus it is safe to use reference here.
22    ///
23    /// Closure `get_initial_value` will be called only once or never called
24    #[wasm_bindgen(js_namespace = React, js_name = useRef)]
25    pub fn use_ref_with(
26        get_initial_value: &mut dyn FnMut() -> JsValue,
27    ) -> MutableRefObject;
28}