redux thunk

· redux
Redux thunk Redux의 비동기 작업을 하기위해 필요한 미들웨어 중 하나 thunk! thunk는 액션객체가 아닌 함수로 디스패치 한다. user의 정보를 가져오는 api 호출을 thunk 를 사용하여 만들어본다고 하면? // 비동기 액션 크리에이터 function userInfoAction(data) { return (dispatch,getState) => { axios.get("api/user") .then((res)=>{ dispatch(userInfoSuccess(res.data)); }) .catch((err)=>{ ... }) } } api를 호출할 비동기 액션 크리에이터를 만들어주었다. thunk에서는 함수를 디스패치할때 dispatch,getState를 파라미터 값으로 받아주어야 ..
이챙(leechaeng)
'redux thunk' 태그의 글 목록