| Conditions | 2 |
| Total Lines | 10 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import React, { useReducer } from "react"; |
||
| 17 | function errorReducer(state: ErrorState, action: ErrorAction) { |
||
| 18 | switch (action.type) { |
||
| 19 | case "push": |
||
| 20 | // Add payload to the end of the array. |
||
| 21 | return { errorQueue: [...state.errorQueue, action.payload] }; |
||
| 22 | case "pop": |
||
| 23 | // Remove the first element of the array. |
||
| 24 | return { errorQueue: state.errorQueue.slice(1) }; |
||
| 25 | default: |
||
| 26 | throw new Error("Undefined action type in errorReducer."); |
||
| 27 | } |
||
| 58 |