(state: Data, action: Action)
| 9 | num: number |
| 10 | } |
| 11 | function reducer(state: Data, action: Action) { |
| 12 | |
| 13 | switch(action.type) { |
| 14 | case 'add': |
| 15 | return { |
| 16 | result: state.result + action.num |
| 17 | } |
| 18 | // state.result += action.num |
| 19 | // return state; |
| 20 | case 'minus': |
| 21 | return { |
| 22 | result: state.result - action.num |
| 23 | } |
| 24 | } |
| 25 | return state; |
| 26 | } |
| 27 | |
| 28 | function App() { |
| 29 | const [res, dispatch] = useReducer<Reducer<Data, Action>, string>(reducer, 'zero', (param) => { |
nothing calls this directly
no outgoing calls
no test coverage detected