반응을 사용 중입니다. react-redux
, redux
입니다. 그런 다음 문제가 생겼습니다. 내가 사용하는 경우 :createStore() 내에서 applyMiddleware를 사용할 때 리스너 상태를 변경할 수 없습니다.
const store = createStore(reducers);
store.subscribe(() => {
console.log(getState());
});
=> 결과 : 난 등/... 주를/업데이트 얻기 위해 파견에게 어떤 행동을 사용할 때 변경할 수 getState()가있는 값을 볼 수 있습니다. 그러나 applyMiddleware를 사용하는 경우. 조치
import indexService from './dashboard/services/services.jsx';
const store = createStore(reducers, applyMiddleware(indexService));
store.dispatch({ type: 'DASHBOARD_GET_CURRENT_DEALS' });
이것은 당신의 도움이 indexService
구성 요소
import { config } from '../../helps.jsx';
const indexService = store => next => action => {
switch (action.type) {
case 'DASHBOARD_GET_CURRENT_DEALS':
fetch(config.homeUrl + '/data/_curentDeals.json', {
method: 'GET',
headers: { 'Content-Type': 'application/json' }
}).then(function (response) { return response.json() }).then(function (json) {
next({
type: 'DASHBOARD_GET_CURRENT_DEALS',
json
})
}).catch(function (error) { console.log('erros', error); });
break;
default:
break;
}
};
export default indexService;
감사 인이있을 때 나는 값이 상태에서 변경 표시되지 않습니다; 다음 상태 트리를 반환하는 감소 기능 :
감사에게 행동에 옆에 전화를 튜닝하는 것은 아니다. 시도했지만 여전히 작동하지 않습니다. –
정말 고마워요. 내 실수 . "** next (action); **"( –
:)을 놓쳤습니다. 첫눈에 그다지 놓쳤습니다. –