11#[ cfg( feature = "import-react" ) ]
22macro_rules! wasm_bindgen_react_state_helpers {
33 ( $( $b: item) +) => {
4- #[ wasm_bindgen( inline_js = r#"
5- import * as React from "react";
6- export { React };
7- export function use_state_object(initial_value) {
8- const [state, set_state] = React.useState(initial_value);
9- return { value: state, setter: { set_state } };
10- }
11- export function use_state_auto_clean(initial_value, clean) {
12- const obj = use_state_object(initial_value);
13- const state = obj.value;
14- React.useEffect(() => { clean(state) }, [state]);
15- }
16- "# ) ]
4+ #[ wasm_bindgen( module = "/helpers/use-state-import.js" ) ]
175 extern "C" {
186 $( $b) +
197 }
@@ -23,17 +11,7 @@ macro_rules! wasm_bindgen_react_state_helpers {
2311#[ cfg( not( feature = "import-react" ) ) ]
2412macro_rules! wasm_bindgen_react_state_helpers {
2513 ( $( $b: item) +) => {
26- #[ wasm_bindgen( inline_js = r#"
27- export function use_state_object(initial_value) {
28- const [state, set_state] = React.useState(initial_value);
29- return { value: state, setter: { set_state } };
30- }
31- export function use_state_auto_clean(initial_value, clean) {
32- const obj = use_state_object(initial_value);
33- const state = obj.value;
34- React.useEffect(() => { clean(state) }, [state]);
35- }
36- "# ) ]
14+ #[ wasm_bindgen( module = "/helpers/use-state.js" ) ]
3715 extern "C" {
3816 $( $b) +
3917 }
0 commit comments