This is the reducer:
function carouselGames(state =
{
firstCarousel: {
games: [],
error: ''
},
secondCarousel: {
games: [],
error: ''
},
thirdCarousel: {
games: [],
error: ''
}
}, action){
switch(action.type){
case actions.SET_FIRST_CAROUSEL_GAMES_SUCCESS: {
return {
...state,
firstCarousel: {
...state.firstCarousel,
games: [...action.payload],
error: ''
}
}
}
case actions.SET_FIRST_CAROUSEL_GAMES_ERROR: {
return {
...state,
firstCarousel: {
...state.firstCarousel,
games: [],
error: action.payload
}
}
}
default:
return state;
}
}
It updates the state but does not re-render the component: Click here to see that the objects now contain a game prop with 3 arrays
Did I make some mistake on the reducer? I searched a lot for updating nested objects and re-checked it so many times but it just does not work...