score:0

Accepted answer

the bug is caused by mutating state in the reducer

        // this is mutating the prepinfos property in state
        return state.prepinfos.map(prepinfo => {
            if (prepinfo.id == data.id) {
                return {...prepinfo, [data.name]: data.value}
            };
            return prepinfo;
        });

        // this is creating and returning a new obj for state and the prepinfos key in state
        return {
          ...state,
          prepinfos: state.prepinfos.map(prepinfo => {
            if (prepinfo.id == data.id) {
                return {...prepinfo, [data.name]: data.value}
            };
            return prepinfo;
        }

Related Query

More Query from same tag