error_boundary.rs 528 B

1234567891011121314151617181920212223242526272829303132
  1. #![allow(non_snake_case)]
  2. use dioxus::prelude::*;
  3. #[test]
  4. fn catches_panic() {
  5. let mut dom = VirtualDom::new(app);
  6. dom.rebuild(&mut dioxus_core::NoOpMutations);
  7. }
  8. fn app() -> Element {
  9. rsx! {
  10. div {
  11. h1 { "Title" }
  12. NoneChild {}
  13. ThrowChild {}
  14. }
  15. }
  16. }
  17. fn NoneChild() -> Element {
  18. VNode::empty()
  19. }
  20. fn ThrowChild() -> Element {
  21. Err(std::io::Error::new(std::io::ErrorKind::AddrInUse, "asd"))?;
  22. let _g: i32 = "123123".parse()?;
  23. rsx! { div {} }
  24. }