2
다음과 같이 호출하는 두 가지 동작이 있습니다. 뷰가 처음로드Redux 동작이 두 번째로 호출되지 않음
export function action1(params) {
//This line is always called.
return (dispatch) => {
//This line is not called the second time.
return MyApi.call1(params)
.then(response => {
// some logic
return dispatch(someFunction1());
})
.catch(error => {
throw(error);
});
};
}
export function action2(params) {
return (dispatch) => {
return MyApi.call2(params)
.then(response => {
// call the first API again
action1();
return dispatch(someFunction2());
})
.catch(error => {
throw(error);
});
};
}
, action1
는 뷰의 생성자에서 호출된다. 작업을 수행하고 action2
을 동일한보기에서 트리거하면 서버에서 업데이트 된 목록을 얻으려면 을 action2
의 성공에 호출해야합니다. 아쉽게도 action1
을 두 번 호출하면 오류없이 코드가 중단됩니다.
무엇이 여기에 있습니까?
btw, 당신은 action1을 발송하지 않았습니다 :'dispatch (action1 (params))'; –
효과가있었습니다. 그것은 내 바보 같았습니다. 수락 할 수 있도록 답변으로 게시 할 수 있습니까? –