2

I am using redux with react.

I am updating the state which looks like this

state = {
    album: {
      name: 'Blood, Sugar, Sex, Magik'
      date: '1991',
      artist: 'RHCP'
   }
}

The relevant part of my reducer looks like this

case 'UPDATE_ALBUM_NAME_SUCCESS':

    return {
        ...state,
        album: {
            ...album,
            name: action.name,

        },

    };

action.name is 'Californication'

I want to just update the album name, however, my code is deleting all the other parts of album and just leaving the album.name. Can anyone advise how to do this properly?

1 Answer 1

4

It should be ...state.album instead of ...album.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.