alternative.rs 942 B

123456789101112131415161718192021222324252627282930
  1. fn main() {}
  2. use dioxus_core::prelude::*;
  3. static Example: FC<()> = |ctx| {
  4. ctx.render(dioxus_core::prelude::LazyNodes::new(move |ctx| {
  5. let bump = ctx.bump();
  6. dioxus::builder::ElementBuilder::new(ctx, "h1")
  7. .children([{
  8. use bumpalo::core_alloc::fmt::Write;
  9. let mut s = bumpalo::collections::String::new_in(bump);
  10. write!(s, "hello");
  11. dioxus::builder::text2(s)
  12. }])
  13. .finish()
  14. }))
  15. };
  16. struct Props {
  17. text: String,
  18. }
  19. static Example2: FC<Props> = |ctx| {
  20. ctx.render(dioxus_core::prelude::LazyNodes::new(move |__ctx| {
  21. let bump = __ctx.bump();
  22. dioxus::builder::ElementBuilder::new(__ctx, "h1")
  23. .children([{ dioxus::builder::text3(bump, format_args!("{}", ctx.text)) }])
  24. // .children([{ dioxus::builder::text3(bump, format_args!("hello")) }])
  25. .finish()
  26. }))
  27. };