redux-saga runAllEffect 에러 해결하기

클론코딩을 하던 중 이런 에러를 마주하였다.

스크롤을 내려보면 runAllEffect에서 발생한 에러임을 알 수 있다.
TypeError: Cannot read property ‘forEach’ of null

runAllEffect 에러

해결방안

액션을 구독할 때에 take함수를 쓰는데, import를 해주지 않아서 발생한 에러였다. take를 import 해주었다.
자바스크립트라 어이없는 실수가 많다..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { all, delay, fork, take } from "redux-saga/effects";

// function logInAPI(data) {
// return axios.post("/api/login");
// }

function* logIn(data) {
try {
// const result = yield call(logInAPI, action.data);
yield delay(1000);
yield put({
type: "LOG_IN_SUCCESS",
data: action.data,
});
} catch (err) {
yield put({
type: "LOG_IN_FAILURE",
data: err.response.data,
});
}
}

function* logOut() {
try {
yield delay(1000);
yield put({
type: LOG_OUT_SUCCESS,
});
} catch (err) {
console.error(err);
yield put({
type: LOG_OUT_FAILURE,
error: err.response.data,
});
}
}

function* watchLogIn() {
yield take("LOG_IN_REQUEST", logIn);
}

function* watchLogOut() {
yield take("LOG_OUT_REQUEST", logOut);
}

export default function* userSaga() {
yield all([fork(watchLogIn), fork(watchLogOut)]);
}
Server Error TypeError: Cannot read property 'forEach' of null

This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
end
file:///C:/Users/SDPark-pc/Desktop/REACT/nodebird/front/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js (1017:18)
Object.abort
file:///C:/Users/SDPark-pc/Desktop/REACT/nodebird/front/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js (817:5)

file:///C:/Users/SDPark-pc/Desktop/REACT/nodebird/front/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js (598:22)
immediately
file:///C:/Users/SDPark-pc/Desktop/REACT/nodebird/front/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js (60:12)
runForkEffect
file:///C:/Users/SDPark-pc/Desktop/REACT/nodebird/front/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js (588:3)
runEffect
file:///C:/Users/SDPark-pc/Desktop/REACT/nodebird/front/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js (1208:7)
digestEffect
file:///C:/Users/SDPark-pc/Desktop/REACT/nodebird/front/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js (1275:5)

file:///C:/Users/SDPark-pc/Desktop/REACT/nodebird/front/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js (677:5)
Array.forEach

runAllEffect
file:///C:/Users/SDPark-pc/Desktop/REACT/nodebird/front/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js (676:8)

댓글