Refresh components after modifying Redux store

Viewed 25

After creating a store, when I modify datas from JASON file, the refresh arrive at the connect function but the component is not rebuild.

I think it's caused by the immutability, I got something

Store

function songReduceur(state = initialState, action) {
    switch (action.type) {
        case CONSTANTS.DELETE_CHORD:
            let DELETE_C_newChordOrder = state.mesures[action.mesure].chordOrder
            DELETE_C_newChordOrder.splice(action.index, 1)

            return {
                ...state,
                mesures:{
                    ...state.mesures,
                    [action.mesure]: {
                        ...state.mesures[action.mesure],
                        chordOrder: DELETE_C_newChordOrder
            }}}
        default:
            return state
    }
}

export default songReduceur

Component

Here the state is update but not on the component MesureArea itself

const mapStateToProps = (state, ownProps) => {
    const id = ownProps.id
    return {
        chiffrage: state.song.mesures[id].chiffrage,
        chordOrder: state.song.mesures[id].chordOrder,
        chordHistoric: state.song.chordHistoric
    }
}

export default connect(mapStateToProps)(MesureArea)
1 Answers

The Solution

The mistake is again the immutability x) it's something like

chordOrder: [...DELETE_C_newChordOrder]
Related