dioxus/examples/xss_safety.rs
Jonathan Kelley a8952a9ee8 fix: exampels
2022-01-25 21:41:40 -05:00

27 lines
607 B
Rust

//! XSS Safety
//!
//! This example proves that Dioxus is safe from XSS attacks.
use dioxus::prelude::*;
fn main() {
dioxus::desktop::launch(app);
}
fn app(cx: Scope) -> Element {
let (contents, set_contents) = use_state(&cx, || {
String::from("<script>alert(\"hello world\")</script>")
});
cx.render(rsx! {
div {
h1 {"Dioxus is XSS-Safe"}
h3 { "{contents}" }
input {
value: "{contents}",
r#type: "text",
oninput: move |e| set_contents(e.value.clone()),
}
}
})
}