Browse Source

fix: debug multistage edits in desktop

Jonathan Kelley 3 years ago
parent
commit
c19995fed9
4 changed files with 44 additions and 2 deletions
  1. 1 1
      Cargo.toml
  2. 40 0
      examples/flat_router.rs
  3. 1 1
      packages/core/src/scopes.rs
  4. 2 0
      packages/core/src/virtual_dom.rs

+ 1 - 1
Cargo.toml

@@ -72,7 +72,7 @@ dioxus = { path = ".", features = ["desktop", "ssr", "router", "fermi"] }
 fern = { version = "0.6.0", features = ["colored"] }
 fern = { version = "0.6.0", features = ["colored"] }
 criterion = "0.3.5"
 criterion = "0.3.5"
 thiserror = "1.0.30"
 thiserror = "1.0.30"
-
+env_logger = "0.9.0"
 
 
 [[bench]]
 [[bench]]
 name = "create"
 name = "create"

+ 40 - 0
examples/flat_router.rs

@@ -0,0 +1,40 @@
+use dioxus::prelude::*;
+
+use dioxus::router::*;
+
+use dioxus::desktop::tao::dpi::LogicalSize;
+
+fn main() {
+    env_logger::init();
+
+    dioxus::desktop::launch_cfg(app, |c| {
+        c.with_window(|c| {
+            c.with_title("Spinsense Client")
+                .with_inner_size(LogicalSize::new(600, 1000))
+                .with_resizable(false)
+        })
+    })
+}
+
+fn app(cx: Scope) -> Element {
+    cx.render(rsx! {
+        Router {
+            Route { to: "/", "Home" }
+            Route { to: "/games", "Games" }
+            Route { to: "/play", "Play" }
+            Route { to: "/settings", "Settings" }
+
+            p {
+                "----"
+            }
+            nav {
+                ul {
+                    Link { to: "/", li { "Home" } }
+                    Link { to: "/games", li { "Games" } }
+                    Link { to: "/play", li { "Play" } }
+                    Link { to: "/settings", li { "Settings" } }
+                }
+            }
+        }
+    })
+}

+ 1 - 1
packages/core/src/scopes.rs

@@ -440,7 +440,7 @@ impl<'a, P> std::ops::Deref for Scope<'a, P> {
 /// `ScopeId` is a `usize` that is unique across the entire VirtualDOM and across time. ScopeIDs will never be reused
 /// `ScopeId` is a `usize` that is unique across the entire VirtualDOM and across time. ScopeIDs will never be reused
 /// once a component has been unmounted.
 /// once a component has been unmounted.
 #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
 #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))]
-#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
+#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug, PartialOrd, Ord)]
 pub struct ScopeId(pub usize);
 pub struct ScopeId(pub usize);
 
 
 /// A task's unique identifier.
 /// A task's unique identifier.

+ 2 - 0
packages/core/src/virtual_dom.rs

@@ -515,6 +515,8 @@ impl VirtualDom {
             }
             }
         }
         }
 
 
+        println!("committed_mutations: {:?}", committed_mutations);
+
         committed_mutations
         committed_mutations
     }
     }