immutability - Redux state.subscribe returns pointers -


i'm building redux app. in state have following:

{ name:string, address:{...} } 

when i'm doing subscribe state i'm getting them both. problem when i'm modifying address property on component changes on store. after little dig found out that's because address object , it's returns pointer , not copy.

my question how can subscribe store , not been afraid of massing store?

doing object.assign inside subscribe function work feels kind of wired..

this.addressmodel = object.assign({},state.information.address); 

thanks lot.

a few thoughts:

  • first, if you're using react, won't need subscribe store "manually". connect function provided react-redux package generates wrapper components handle subscription process you.
  • second, yes, reducer logic should update data immutably. means ensuring every level of nesting copied.

the redux faq talks immutability in relation react components not re-rendering. redux docs section on structuring reducers includes links articles teaching immutable data management, how update data immutably. have links several other articles on immutable data concepts part of react/redux links list.


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -