1
0
Эх сурвалжийг харах

document get_root_props_from_document

Evan Almloff 2 жил өмнө
parent
commit
581a4648de

+ 1 - 1
packages/server/examples/axum-hello-world/src/main.rs

@@ -14,7 +14,7 @@ fn main() {
     #[cfg(feature = "web")]
     dioxus_web::launch_with_props(
         app,
-        get_props_from_document().unwrap_or_default(),
+        get_root_props_from_document().unwrap_or_default(),
         dioxus_web::Config::new().hydrate(true),
     );
     #[cfg(feature = "ssr")]

+ 1 - 1
packages/server/examples/salvo-hello-world/src/main.rs

@@ -14,7 +14,7 @@ fn main() {
     #[cfg(feature = "web")]
     dioxus_web::launch_with_props(
         app,
-        get_props_from_document().unwrap_or_default(),
+        get_root_props_from_document().unwrap_or_default(),
         dioxus_web::Config::new().hydrate(true),
     );
     #[cfg(feature = "ssr")]

+ 1 - 1
packages/server/examples/warp-hello-world/src/main.rs

@@ -14,7 +14,7 @@ fn main() {
     #[cfg(feature = "web")]
     dioxus_web::launch_with_props(
         app,
-        get_props_from_document().unwrap_or_default(),
+        get_root_props_from_document().unwrap_or_default(),
         dioxus_web::Config::new().hydrate(true),
     );
     #[cfg(feature = "ssr")]

+ 1 - 1
packages/server/src/lib.rs

@@ -26,7 +26,7 @@ pub mod prelude {
     #[cfg(feature = "warp")]
     pub use crate::adapters::warp_adapter::*;
     #[cfg(not(feature = "ssr"))]
-    pub use crate::props_html::deserialize_props::get_props_from_document;
+    pub use crate::props_html::deserialize_props::get_root_props_from_document;
     #[cfg(feature = "ssr")]
     pub use crate::render::SSRState;
     #[cfg(feature = "ssr")]

+ 3 - 1
packages/server/src/props_html/deserialize_props.rs

@@ -20,7 +20,9 @@ pub(crate) fn serde_from_string<T: DeserializeOwned>(string: &str) -> Option<T>
 
 #[cfg(not(feature = "ssr"))]
 /// Get the props from the document. This is only available in the browser.
-pub fn get_props_from_document<T: DeserializeOwned>() -> Option<T> {
+///
+/// When dioxus-server renders the page, it will serialize the root props and put them in the document. This function gets them from the document.
+pub fn get_root_props_from_document<T: DeserializeOwned>() -> Option<T> {
     #[cfg(not(target_arch = "wasm32"))]
     {
         None