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