중첩 된 reducers 작업 예제를 살펴 보았지만 매우 이상한 문제가 있습니다.combinereducers를 사용하여 중첩 된 redux reducers 들러 붙어
window.store = configureStore({
slider: {
mainImageIndex: 0,
pageNum: 1,
perPage: 4, // Per supplied requirements
},
});
가 내하는 index.js 감속기에 다음 (모든 수입 제외) :
export default combineReducers({
searchPhotos,
slider: combineReducers({
mainImageIndex: setMainImage,
pageNum: nextPage,
perPage: setPerPage,
}),
form: reduxFormReducer, // mounted under "form"
});
나는 다음과 같은 초기 상태가
그리고 내 setMainInage.js 감속기 : 첨부
export default (state = {}, action) => {
switch (action.type) {
case 'SET_MAIN_IMAGE':
return {
...state,
mainImageIndex: action.mainImageIndex,
};
default:
return state;
}
};
가 이전과 REDUX의 DevTools로의 화면 잡고 후입니다. SET_MAIN_IMAGE를 호출 한 후 슬라이더 노드 내의 계층 구조가 변경됩니다. mainImageIndex를 업데이트하는 대신 몇 가지 이유로 원래의 새 mainImageIndex 키를 중첩합니다. 누구든지 그 원인을 알 수 있습니까?
이 문제는 redux-immutable을 사용해야한다고 생각합니다. 중첩 된 객체는 불변이어야합니다. –
이 아이디어를 따르려고했지만 뭔가 빠져 있어야합니다. https://github.com/reactjs/redux/issues/738 – pixelwiz