1
0

lifecycle.rs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. use dioxus_core::prelude::*;
  2. fn main() {
  3. // let mut s = Context { props: &() };
  4. // let g = Component(&mut s);
  5. }
  6. // struct CompState {
  7. // tasks: Vec<()>,
  8. // }
  9. // enum Actions {
  10. // Add,
  11. // MoveUp,
  12. // MoveDown,
  13. // Remvoe,
  14. // }
  15. // static Component: FC<()> = |ctx| {
  16. // let (tasks, dispatch) = use_reducer(
  17. // ctx,
  18. // || CompState { tasks: Vec::new() },
  19. // |state, action: Actions| match action {
  20. // Actions::Add => state,
  21. // Actions::MoveUp => state,
  22. // Actions::MoveDown => state,
  23. // Actions::Remvoe => state,
  24. // },
  25. // );
  26. // let tasklist = { (0..10).map(|f| html! { <li></li> }) }.collect::<Vec<_>>();
  27. // html! {
  28. // <div>
  29. // <div>
  30. // <h1>"Tasks: "</h1>
  31. // <ul>
  32. // {tasklist}
  33. // </ul>
  34. // </div>
  35. // <div>
  36. // <button onclick=|_| dispatch(Action::Add)>{"Add"}</button>
  37. // <button onclick=|_| dispatch(Action::MoveUp)>{"MoveUp"}</button>
  38. // <button onclick=|_| dispatch(Action::MoveDown)>{"MoveDown"}</button>
  39. // <button onclick=|_| dispatch(Action::Remvoe)>{"Remvoe"}</button>
  40. // </div>
  41. // </div>
  42. // }
  43. // };
  44. // fn use_reducer<Props, State, Action>(
  45. // ctx: &mut Context<Props>,
  46. // init: fn() -> State,
  47. // reducer: fn(State, Action) -> State,
  48. // ) -> (State, impl Fn(Action)) {
  49. // let ii = init();
  50. // (ii, |_| {})
  51. // }