How to update the state of an object in react-redux

My question might sound stupid but I swear my brain freeze, I google it for answer but honestly I don’t even know what should I search for. So basically I have a reducer, usually when I’m using redux I’m using arrays and my reducers look like this:

import { FETCH_ALL, CREATE, UPDATE, DELETE } from '../constants/actionTypes';

export default (posts = [], action) => {
  switch (action.type) {
    case FETCH_ALL:
      return action.payload;
    case CREATE:
        return [...posts, action.payload];
    case UPDATE:
        return posts.map((post) => post._id === action.payload._id ? action.payload : post);
    case DELETE:
        return posts.filter((post) => post._id !== action.payload);
    default:
      return posts;
  }
};

And now I only have an object, and I really don’t know what to write on case UPDATE, I mean I’m not looping through and find my updated object and that process. My question is how can I update if I only have an object

import { FETCH_PROFILE, UPDATE_PROFILE } from '../constants';

export default (profile= {}, action) => {
  switch (action.type) {
    case FETCH_PROFILE:
      return action.payload;
    case UPDATE_PROFILE:
      return ;
    default:
      return profile;
  }
};

like here, in that case UPDATE_PROFILE, what should I write to make it work, in my backend everything going well, the return is an object with the updated user. I know my question is stupid, but please be kind! Thank you in advance

    Unexpected token, expected "," (8:32)

   6 |       return action.payload;
   7 |     case UPDATE_PROFILE:
>  8 |       return {...profile, action.payload};
     |                                 ^
   9 |     default:
  10 |       return profile;
  11 |   }

Answer

For object you will use spread operator just like in an array:

import { FETCH_PROFILE, UPDATE_PROFILE } from '../constants';

export default (profile= {}, action) => {
  switch (action.type) {
    case FETCH_PROFILE:
      return action.payload;
    case UPDATE_PROFILE:
      return {...profile, action.payload};
    default:
      return profile;
  }
};

More about it here.