react/node/
value.rs

1use wasm_bindgen::JsValue;
2
3/// A `number`, `string`, `boolean` or `Array<ReactNode>`
4/// that are not elements
5/// but valid `ReactNode`
6#[derive(Debug, Clone)]
7pub struct AnyNodeValue {
8    inner: JsValue,
9}
10
11impl AnyNodeValue {
12    #[inline]
13    pub(crate) fn unsafe_from_js_react_node(js_value: JsValue) -> Self {
14        Self { inner: js_value }
15    }
16
17    /// ## Safety:
18    /// Please make sure the js value is a valid `ReactNode`
19    #[inline]
20    pub unsafe fn from_js_react_node(js_value: JsValue) -> Self {
21        Self::unsafe_from_js_react_node(js_value)
22    }
23}
24
25impl AsRef<JsValue> for AnyNodeValue {
26    #[inline]
27    fn as_ref(&self) -> &JsValue {
28        &self.inner
29    }
30}
31
32impl Into<JsValue> for AnyNodeValue {
33    fn into(self) -> JsValue {
34        self.inner
35    }
36}