0

I'm working on react/redux for some months, and I create this generic method which is a setState like but for redux state. It work well, but it when I try to use redux dev tools, it crashed.

Is there some obvious reason for that ? I don't have any error message, just : redux devtool has crashed

case AFFECTVALUE:
            console.log('--> AFFECTVALUE action :', action.name, action.value);
            var newState = { ...state };
            newState[action.name] = action.value
            return {
                ...newState
            }
LexaGC
  • 110
  • 3
  • 13
  • The only weird thing in the code is that you clone the state twice. – wOxxOm Sep 12 '19 at 08:03
  • If the `Redux DevTools` detect a flow of actions that consume too many resources this will crash because can handle all the "side effects" of the reducer. I'll recommend you to check how many changes is your action making, in order to make it shorter. – Alberto Perez Sep 12 '19 at 10:21
  • @wOxxOm Hi thanks for reply, where did you see I clone it twice ? I clone it just once when I make a copy of the old state and then I return the whole new state. Which could be probably the error, maybe I should return just the modify key as you said AlbertoPerez . thanks for answer me guys I try and come back – LexaGC Sep 13 '19 at 10:27
  • 1
    First clone is `{...state}`, second unnecessary clone is `{...newState}`. – wOxxOm Sep 13 '19 at 10:58

1 Answers1

0

Seems like you should just have return newState;