I have an action FETCH_HABITS_SUCCESS that's called with the right data:
but it affects a reducer that isn't listening to it:
Dates reducer doesn't listen to FETCH_HABIT_SUCCESS. The data shown in the diff from the previous image should be the one from UNMARK_SUCCESS (two actions later in the execution timeline).
For some reason, the UNMARK_SUCCESS action real modifications take place when FETCH_HABIT_SUCCESS is called, at least that's what the dev tools show. I have checked that all my reducers don't mutate state. I always make a copy of the state. People at Reactiflux have checked that I don't mutate state too.
Code:
dates reducer: https://www.pastiebin.com/5a03538e98322 habits reducer:
export default function habits(state = {}, action) {
const newState = { ...state };
switch (action.type) {
case 'FETCH_HABITS_SUCCESS':
action.habits.forEach(habit => { newState[habit.id] = habit; });
return newState;
case 'ADD_HABIT_SUCCESS':
case 'EDIT_HABIT_SUCCESS':
newState[action.habit.id] = action.habit;
return Object.assign({}, state, newState);
case 'DELETE_HABIT_SUCCESS':
delete newState[action.habit_id];
return newState;
default: return state;
}
}
Does anyone have any idea of what may I be doing wrong?