Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type item = {
- id: int,
- title: string,
- completed: bool,
- };
- type state = {
- id: int, // id for a new item
- items: list(item),
- };
- [@react.component]
- let make = (~title) => {
- let ({items}, dispatch) =
- React.useReducer(
- (state, action) => {
- let items =
- List.map(
- item => {id: 0, title: "", completed: false},
- state.items,
- );
- {id: state.id, items};
- },
- {
- id: 1,
- items: [{id: 0, title: "Write some things to do", completed: false}],
- },
- );
- <div className="items">
- {React.array(
- Array.of_list(
- List.map(item => <div>(React.string(item.title))</div>, items),
- ),
- )}
- </div>;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement