Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. type item = {
  2. id: int,
  3. title: string,
  4. completed: bool,
  5. };
  6.  
  7. type state = {
  8. id: int, // id for a new item
  9. items: list(item),
  10. };
  11.  
  12. [@react.component]
  13. let make = (~title) => {
  14. let ({items}, dispatch) =
  15. React.useReducer(
  16. (state, action) => {
  17. let items =
  18. List.map(
  19. item => {id: 0, title: "", completed: false},
  20. state.items,
  21. );
  22. {id: state.id, items};
  23. },
  24. {
  25. id: 1,
  26. items: [{id: 0, title: "Write some things to do", completed: false}],
  27. },
  28. );
  29. <div className="items">
  30. {React.array(
  31. Array.of_list(
  32. List.map(item => <div>(React.string(item.title))</div>, items),
  33. ),
  34. )}
  35. </div>;
  36. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement