1
0

rsx_compile_fail.rs 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. use dioxus::prelude::*;
  2. fn main() {
  3. let mut vdom = VirtualDom::new(example);
  4. vdom.rebuild();
  5. let out = dioxus::ssr::render_vdom_cfg(&vdom, |c| c.newline(true).indent(true));
  6. println!("{}", out);
  7. }
  8. fn example(cx: Scope) -> Element {
  9. let items = use_state(&cx, || {
  10. vec![Thing {
  11. a: "asd".to_string(),
  12. b: 10,
  13. }]
  14. });
  15. let things = use_ref(&cx, || {
  16. vec![Thing {
  17. a: "asd".to_string(),
  18. b: 10,
  19. }]
  20. });
  21. let things_list = things.read();
  22. let mything = use_ref(&cx, || Some(String::from("asd")));
  23. let mything_read = mything.read();
  24. cx.render(rsx!(
  25. div {
  26. div {
  27. id: "asd",
  28. "your neighborhood spiderman"
  29. items.iter().cycle().take(5).map(|f| rsx!{
  30. div {
  31. "{f.a}"
  32. }
  33. })
  34. things_list.iter().map(|f| rsx!{
  35. div {
  36. "{f.a}"
  37. "{f.b}"
  38. }
  39. })
  40. mything_read.as_ref().map(|f| rsx!{
  41. div {
  42. "{f}"
  43. }
  44. })
  45. }
  46. }
  47. ))
  48. }
  49. struct Thing {
  50. a: String,
  51. b: u32,
  52. }