How to update nested props or states in reducer (React Redux)

April 19, 2021

To go even deeper you can do the following:

function BitFritUpdateState(state, action) {
    return {
        ...state,
        BitFrit : {
            ...state.BitFrit,
            second : {
                ...state.BitFrit.second,
                [action.someId] : {
                    ...state.BitFrit.second[action.someId],
                    fourth : action.someValue
                }
            }
        }
    }
}

Written by Manoj Bhardwaj who lives and works in Dharamshala Himachal Pradesh (India). My stackoverflow