MCPcopy Create free account
hub / github.com/QuarkGluonPlasma/react-course-code / reducer

Function reducer

hook-test/src/App3.tsx:11–26  ·  view source on GitHub ↗
(state: Data, action: Action)

Source from the content-addressed store, hash-verified

9 num: number
10}
11function 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
28function App() {
29 const [res, dispatch] = useReducer<Reducer<Data, Action>, string>(reducer, 'zero', (param) => {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected