step.rs 688 B

123456789101112131415161718192021222324252627282930313233343536
  1. //! An example that shows how to:
  2. //! create a scope,
  3. //! render a component,
  4. //! change some data
  5. //! render it again
  6. //! consume the diffs and write that to a renderer
  7. use dioxus_core::{
  8. prelude::*,
  9. virtual_dom::{Properties, Scope},
  10. };
  11. fn main() {
  12. let mut scope = Scope::new(Example);
  13. let ctx = scope.create_context::<Props>();
  14. let p1 = Props { name: "bob".into() };
  15. let p2 = Props { name: "bob".into() };
  16. }
  17. struct Props {
  18. name: String,
  19. }
  20. impl Properties for Props {
  21. fn new() -> Self {
  22. todo!()
  23. }
  24. }
  25. static Example: FC<Props> = |ctx| {
  26. ctx.view(html! {
  27. <div>
  28. <h1> </h1>
  29. </div>
  30. })
  31. };