custom_element.rs 974 B

1234567891011121314151617181920212223242526272829303132
  1. //! This example shows to wrap a webcomponent / custom element with a component.
  2. //!
  3. //! Oftentimes, a third party library will provide a webcomponent that you want
  4. //! to use in your application. This example shows how to create that custom element
  5. //! directly with the raw_element method on NodeFactory.
  6. use dioxus::prelude::*;
  7. fn main() {
  8. let mut dom = VirtualDom::new(app);
  9. let _ = dom.rebuild();
  10. let output = dioxus_ssr::render(&dom);
  11. println!("{}", output);
  12. }
  13. fn app(cx: Scope) -> Element {
  14. // let nf = NodeFactory::new(cx);
  15. // let mut attrs = dioxus::core::exports::bumpalo::collections::Vec::new_in(nf.bump());
  16. // attrs.push(nf.attr("client-id", format_args!("abc123"), None, false));
  17. // attrs.push(nf.attr("name", format_args!("bob"), None, false));
  18. // attrs.push(nf.attr("age", format_args!("47"), None, false));
  19. // Some(nf.raw_element("my-element", None, &[], attrs.into_bump_slice(), &[], None))
  20. todo!()
  21. }