From 6df19db16eb9fcb4a48e5b789e1e0f92d41454f9 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 17 Nov 2025 18:32:00 +0000 Subject: [PATCH] fix: Move Nostr client initialization inside Dioxus runtime context Resolves runtime panic "Must be called from inside a Dioxus runtime" by moving init_nostr_client() from lib.rs::init() (which runs before the runtime starts) to the App component using use_effect (which runs inside the runtime context). The GlobalSignal and spawn() APIs require the Dioxus runtime to be active, so initializing the Nostr client must happen after dioxus::launch() has started. Changes: - src/lib.rs: Removed init_nostr_client() call from init() - src/main.rs: Added use_effect hook in App component to initialize the Nostr client within the runtime context Fixes the error: panicked at dioxus-core-0.7.1/src/runtime.rs:100:17: Must be called from inside a Dioxus runtime. --- src/lib.rs | 4 ++-- src/main.rs | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5c7d528..a9d9668 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,6 +33,6 @@ pub fn init() { tracing::info!("VBStack initialized"); - // Initialize Nostr client - hooks::use_nostr_client::init_nostr_client(); + // Note: Nostr client initialization moved to App component + // to run within Dioxus runtime context } diff --git a/src/main.rs b/src/main.rs index 19f0b12..c024434 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,13 @@ fn main() { /// Root application component #[component] fn App() -> Element { + use vbstack::hooks::use_nostr_client::init_nostr_client; + + // Initialize Nostr client within the Dioxus runtime + use_effect(move || { + init_nostr_client(); + }); + rsx! { Router:: {} }