Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Returning values from eval fails on dioxus web #3655

Closed
ealmloff opened this issue Jan 27, 2025 · 0 comments · Fixed by #3656
Closed

Returning values from eval fails on dioxus web #3655

ealmloff opened this issue Jan 27, 2025 · 0 comments · Fixed by #3656
Assignees
Labels
bug Something isn't working web relating to the web renderer for dioxus

Comments

@ealmloff
Copy link
Member

ealmloff commented Jan 27, 2025

Problem

Returning a value in document::eval only works on dioxus desktop and fails in dioxus web. This is causing DioxusLabs/docsite#398 (also mentioned in #3574)

Steps To Reproduce

  1. Run this code in dioxus desktop and dioxus web and click the button:
use dioxus::prelude::*;

fn main() {
    dioxus::launch(App);
}

#[component]
fn App() -> Element {
    rsx! {
        button {
            onclick: |_| async move {
                let output = document::eval("return 'Hello world!';").await.unwrap();
                assert_eq!(output, "Hello world!");
            },
            "Click me"
        }
    }
}
  1. Observe the web version panics.

Expected behavior

Returning a value from eval should work the same on all webview based platforms
Screenshots

Environment:

  • Dioxus version: 0.6.2
  • Rust version: nightly
  • OS info: MacOS
  • App platform: web

Questionnaire

I would like to fix and I have a solution

@ealmloff ealmloff added bug Something isn't working web relating to the web renderer for dioxus labels Jan 27, 2025
@ealmloff ealmloff self-assigned this Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working web relating to the web renderer for dioxus
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant