1
0

lifecycle.rs 1.4 KB

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