react_sys/
element.rs

1use wasm_bindgen::prelude::*;
2
3crate::macro_import::wasm_bindgen_react! {
4    #[derive(Debug, Clone)]
5    pub type Element;
6    #[wasm_bindgen(structural, method, getter = r#type)]
7    pub fn kind(this: &Element) -> JsValue;
8
9    #[wasm_bindgen(js_namespace = React, js_name = createElement)]
10    pub fn create_element_no_props(element_type: &JsValue) -> Element;
11
12    #[wasm_bindgen(js_namespace = React, js_name = createElement)]
13    pub fn create_element_no_children(element_type: &JsValue, props: &JsValue) -> Element;
14
15    #[wasm_bindgen(variadic, js_namespace = React, js_name = createElement)]
16    pub fn create_element(
17        element_type: &JsValue,
18        props: &JsValue,
19        children: &js_sys::Array,
20    ) -> Element;
21
22    /// # Safety
23    ///
24    /// the function in `element_type` closure should live longer enough
25    #[wasm_bindgen(variadic, js_namespace = React, js_name = createElement)]
26    pub unsafe fn create_element_fn(
27        element_type: &Closure<dyn Fn(js_sys::Object) -> Element>,
28        props: &JsValue,
29        children: &js_sys::Array,
30    ) -> Element;
31
32    /// # Safety
33    ///
34    /// the function in `element_type` closure should live longer enough
35    #[wasm_bindgen(variadic, js_namespace = React, js_name = createElement)]
36    pub unsafe fn create_element_fn_mut(
37        element_type: &Closure<dyn FnMut(js_sys::Object) -> Element>,
38        props: &JsValue,
39        children: &js_sys::Array,
40    ) -> Element;
41
42    #[wasm_bindgen(js_namespace = React, js_name = createElement)]
43    pub fn create_element_intrinsic_no_props(element_type: &str) -> Element;
44
45    #[wasm_bindgen(js_namespace = React, js_name = createElement)]
46    pub fn create_element_intrinsic_no_children(element_type: &str, props: &JsValue) -> Element;
47
48    #[wasm_bindgen(variadic, js_namespace = React, js_name = createElement)]
49    pub fn create_element_intrinsic(
50        element_type: &str,
51        props: &JsValue,
52        children: &js_sys::Array,
53    ) -> Element;
54}