javascript - Changing redux state but also retain some old values of state -


in react-redux app, changing redux state , looks this

state {     key1: oldval1     key2: oldarray1 //the value here array     .     .     . } 

now when update state next time...

state {     key1: newval1      //but key2 want keep value same oldarray1     //now since oldarray1 not anywhere except in old state, can this...?      key2: state.key2     .     .     . } 

so if key2: state.key2 , state.key2 array, reference lost since state changed , state.key2 won't point anything?

i want rough explanation of how object/array references affect state in redux.

note redux state immutable, first state , second state 2 different objects, can assign old value new key, if use object.assign or immutable tool, of course.

      switch (action.type) {         case set_visibility_filter:           return object.assign({}, state, {             key1: action.newval1,             key2: state.key1,           }) 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -