Slide 7
Slide 7 text
Stateful componentͷྫ(2/3)
let make = (~greeting, _children) => {
...component,
initialState: () => { count:0, show: true},
/* ঢ়ଶભҠ */
reducer: (action, state) =>
switch (action) {
| Click => ReasonReact.Update({...state, count: state.count + 1})
| Toggle => ReasonReact.Update({...state, show: ! state.show})
},
7