You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This is only optional if the second argument wasn't provided
138
-
// let global_state = if fn_args.len() == 2 {
139
-
// match &args.global_state {
140
-
// Some(global_state) => global_state.clone(),
141
-
// None => return syn::Error::new_spanned(&fn_args[0], "template functions with two arguments must declare their global state type (`global_state = `)").to_compile_error()
None => return syn::Error::new_spanned(&fn_args[0],"template functions with two arguments must declare their global state type (`global_state = `)").to_compile_error()
139
+
}
140
+
}else{
141
+
match&args.global_state{
142
+
Some(global_state) => global_state.clone(),
143
+
None => Ident::new("Dummy",Span::call_site()),
144
+
}
145
+
};
149
146
// This is only optional if the first argument wasn't provided
// But we'll need the global state as a variable until a template accesses it, so we'll keep it around (even though it should actually instantiate validly and not need this after the initial load)
116
117
let global_state = format!("window.__PERSEUS_GLOBAL_STATE = `{}`;", global_state);
Copy file name to clipboardExpand all lines: packages/perseus/src/shell.rs
+8-7
Original file line number
Diff line number
Diff line change
@@ -295,19 +295,20 @@ pub async fn app_shell(
295
295
checkpoint("initial_state_present");
296
296
// Unset the initial state variable so we perform subsequent renders correctly
297
297
// This monstrosity is needed until `web-sys` adds a `.set()` method on `Window`
298
+
// We don't do this for the global state because it should hang around uninitialized until a template wants it (if we remove it before then, we're stuffed)
298
299
Reflect::set(
299
300
&JsValue::from(web_sys::window().unwrap()),
300
301
&JsValue::from("__PERSEUS_INITIAL_STATE"),
301
302
&JsValue::undefined(),
302
303
)
303
304
.unwrap();
304
-
// Also do this for the global state
305
-
Reflect::set(
306
-
&JsValue::from(web_sys::window().unwrap()),
307
-
&JsValue::from("__PERSEUS_GLOBAL_STATE"),
308
-
&JsValue::undefined(),
309
-
)
310
-
.unwrap();
305
+
// // Also do this for the global state
306
+
// Reflect::set(
307
+
// &JsValue::from(web_sys::window().unwrap()),
308
+
// &JsValue::from("__PERSEUS_GLOBAL_STATE"),
309
+
// &JsValue::undefined(),
310
+
// )
311
+
// .unwrap();
311
312
// We need to move the server-rendered content from its current container to the reactive container (otherwise Sycamore can't work with it properly)
312
313
let initial_html = initial_container.inner_html();
0 commit comments