본문 바로가기

Redux2

13Mar2020 TIL redux-saga : 비동기적인 일 (data fetch 같은)처럼 side effect 라고 불리는 일련의 일들을 처리하는 라이브러리. 콜백의 지옥을 사용하지 않고, test 가 용이하고 관리가 쉬워 thunk 보다 자주 사용된다. //index.js 시조 component import createSagaMiddleware from "redux-saga"; import { getFetchData } from "./actions/actions"; const sagaMiddleware = createSagaMiddleware(); const store = createStore(todoReducer, applyMiddleware(sagaMiddleware, logger)); sagaMiddleware.ru.. 2020. 3. 13.
11Mar2020 TIL Redux - Thunk : A thunk is another word for a function. But it’s not just any old function. It’s a special (and uncommon) name for a function that’s returned by another. (출처) 단어가 가진 위압감으로 접근하기 어려웠지만, 비동기 처리를 위해 dispatch를 리턴하는 콜백을 함수로 감싸는 것. getDataFetch 겉에 함수는 비동기적으로 처리되게 하기 위한 하나의 장치 같은 느낌이다(뇌피셜. 확실하지 않음). //Actions.js export function getDataFetch(URL) { return dispatch => { dispatch({ type: GE.. 2020. 3. 12.