Fix Dioxus runtime error in WASM initialization - #5
Merged
aljazceru merged 1 commit intoNov 17, 2025
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
Fixes the error:
panicked at dioxus-core-0.7.1/src/runtime.rs:100:17: Must be called from inside a Dioxus runtime.