File tree Expand file tree Collapse file tree 3 files changed +44
-7
lines changed
Expand file tree Collapse file tree 3 files changed +44
-7
lines changed Original file line number Diff line number Diff line change 1+ use wasm_bindgen:: prelude:: * ;
2+
3+ crate :: macro_import:: wasm_bindgen_react! {
4+ pub type Element ;
5+ #[ wasm_bindgen( structural, method, getter = r#type) ]
6+ pub fn kind( this: & Element ) -> JsValue ;
7+
8+ #[ wasm_bindgen( js_namespace = React , js_name = createElement) ]
9+ pub fn create_element_no_props( element_type: & JsValue ) -> Element ;
10+
11+ #[ wasm_bindgen( js_namespace = React , js_name = createElement) ]
12+ pub fn create_element_with_props( element_type: & JsValue , props: JsValue ) -> Element ;
13+
14+ #[ wasm_bindgen( variadic, js_namespace = React , js_name = createElement) ]
15+ pub fn create_element(
16+ element_type: & JsValue ,
17+ props: JsValue ,
18+ children: js_sys:: Array ,
19+ ) -> Element ;
20+ }
Original file line number Diff line number Diff line change 1- #[ cfg( test) ]
2- mod tests {
3- #[ test]
4- fn it_works ( ) {
5- assert_eq ! ( 2 + 2 , 4 ) ;
6- }
7- }
1+ mod element;
2+ mod macro_import;
3+ pub use element:: * ;
Original file line number Diff line number Diff line change 1+ #[ cfg( feature = "import-react" ) ]
2+ macro_rules! wasm_bindgen_react {
3+ ( $( $b: item) +) => {
4+ #[ wasm_bindgen]
5+ extern "C" {
6+ $( $b) +
7+ }
8+ } ;
9+ }
10+
11+ #[ cfg( not( feature = "import-react" ) ) ]
12+ macro_rules! wasm_bindgen_react {
13+ ( $( $b: item) +) => {
14+ #[ wasm_bindgen( inline_js = r#"export * as React from "react";"# ) ]
15+ extern "C" {
16+ $( $b) +
17+ }
18+ } ;
19+ }
20+
21+ pub ( crate ) use wasm_bindgen_react;
You can’t perform that action at this time.
0 commit comments