react_sys/
use_effect.rs

1use wasm_bindgen::prelude::*;
2
3crate::macro_import::wasm_bindgen_react! {
4    /// `React.useEffect(effect, dependencies)`
5    ///
6    /// # Safety
7    ///
8    /// `effect` should be a js function.
9    ///
10    /// If `effect` is the value returned from `Closure::once_into_js()`.
11    /// You need to make sure `effect` changes if and only if
12    /// `dependencies` change.
13    /// If `dependencies` change but `effect` doesn't change,
14    /// `effect` will be called more than once.
15    /// If `effect` but `dependencies` doesn't change,
16    /// `effect` will never be called causing memory leak.
17    ///
18    #[wasm_bindgen(js_namespace = React, js_name = useEffect)]
19    pub unsafe fn use_effect(effect: JsValue, dependencies: js_sys::Array);
20
21    /// `React.useEffect(effect)`
22    ///
23    /// # Safety
24    ///
25    /// `effect` should be a js function.
26    ///
27    /// It can the value returned from `Closure::once_into_js()`.
28    ///
29    #[wasm_bindgen(js_namespace = React, js_name = useEffect)]
30    pub unsafe fn use_effect_on_each_render(effect: JsValue);
31}