728x90
반응형
에러 메시지
Unnecessary 'else' after 'return'.
코드
vanilla redux에서 reducer 선언하는 중 action의 조건문에서 발생
const countModifier = (count = 0, action) => {
console.log(count, action);
if (action.type === "ADD") {
return count + 1;
} else if (action.type === "MINUS") {
return count - 1;
}
return count;
};
해결법
else if문 대신 -> if문 사용
const countModifier = (count = 0, action) => {
console.log(count, action);
if (action.type === "ADD") {
return count + 1;
}
if (action.type === "MINUS") {
return count - 1;
}
return count;
};728x90
반응형
'ERROR' 카테고리의 다른 글
| ERR_NAME_NOT_RESOLVED 오류 (0) | 2025.10.03 |
|---|---|
| DNS_PROBE_FINISHED_NXDOMAIN (0) | 2025.10.03 |
| 사이트에 연결할 수 없습니다 :: DNS_PROBE_FINISHED_NXDOMAIN (0) | 2025.09.25 |
| Error 1034 : Edge IP restricted :: Ray ID (0) | 2025.09.25 |
| ESlint error: Default parameters should be last. (0) | 2023.02.27 |
| ESLint Error: Assignment (=) can be replaced with operator assignment (-=) & Unary operator '--' used (0) | 2023.02.27 |
| eslint Error: A form label must be associated with a control. (0) | 2023.02.16 |
| react 에러: React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object (0) | 2023.02.02 |