dioxus/examples/custom_element.rs

33 lines
974 B
Rust
Raw Normal View History

2022-04-24 23:44:20 +00:00
//! This example shows to wrap a webcomponent / custom element with a component.
//!
//! Oftentimes, a third party library will provide a webcomponent that you want
//! to use in your application. This example shows how to create that custom element
//! directly with the raw_element method on NodeFactory.
use dioxus::prelude::*;
fn main() {
let mut dom = VirtualDom::new(app);
let _ = dom.rebuild();
2022-12-07 01:50:25 +00:00
let output = dioxus_ssr::render(&dom);
2022-04-24 23:44:20 +00:00
println!("{}", output);
}
fn app(cx: Scope) -> Element {
// let nf = NodeFactory::new(cx);
2022-04-24 23:44:20 +00:00
2022-11-16 07:22:41 +00:00
// let mut attrs = dioxus::core::exports::bumpalo::collections::Vec::new_in(nf.bump());
2022-04-24 23:44:20 +00:00
2022-11-16 07:22:41 +00:00
// attrs.push(nf.attr("client-id", format_args!("abc123"), None, false));
2022-04-24 23:44:20 +00:00
2022-11-16 07:22:41 +00:00
// attrs.push(nf.attr("name", format_args!("bob"), None, false));
2022-04-24 23:44:20 +00:00
2022-11-16 07:22:41 +00:00
// attrs.push(nf.attr("age", format_args!("47"), None, false));
2022-04-24 23:44:20 +00:00
2022-11-16 07:22:41 +00:00
// Some(nf.raw_element("my-element", None, &[], attrs.into_bump_slice(), &[], None))
todo!()
2022-04-24 23:44:20 +00:00
}