lifecycle.rs 1.5 KB

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