generic_component.rs 424 B

123456789101112131415161718192021222324
  1. use std::fmt::Display;
  2. use dioxus::prelude::*;
  3. fn main() {
  4. dioxus_desktop::launch(app);
  5. }
  6. fn app(cx: Scope) -> Element {
  7. render! {
  8. generic_child { data: 0 }
  9. }
  10. }
  11. #[derive(PartialEq, Props)]
  12. struct GenericChildProps<T: Display + PartialEq> {
  13. data: T,
  14. }
  15. fn generic_child<T: Display + PartialEq>(cx: Scope<GenericChildProps<T>>) -> Element {
  16. render! {
  17. div { "{&cx.props.data}" }
  18. }
  19. }