3

Pretty sure my team isn't following best practices in terms of managing state with redux and react... We are already having to rewrite most of the project because they were mutating the state EVERYWHERE. Glad they got the css looking decent so they could hide behind that for a couple of months.

Comments
  • 0
    State is pretty hard to mutate if you use immutable.
  • 1
    Yeah they didn't before but I'm working on adding it now. That's what a lot of the refactoring is, adding immutable and normalizing the store... Amongst other things...
  • 0
    I am mildly shocked that your team is actually able to mutate a state and still get a response out of a component. When I started with React, I implemented a redux store with immutable simply because it was the easiest way I could figure out how to get a component to update.

    Granted, back then, I had very little understanding of how the components update and how the redux store plays a part in this.

    Also before immutable, I tried a method for cloning objects to provide a state change but it was not compatible in IE. I try to forget those days.

    Now I just wish I had more projects that included React and Redux.
  • 0
    @avstuff haha it was only working for one view and when we added the immutable records to our state, the project basically imploded lol jk but I mean it was pretty bad
  • 0
    @reduxtris possibly a mapStateToProps binding issue? I think immutable object attributes must be retrieved with the get or getIn methods. Quick fix would be to toJS the state and retrieve attributes using dot notation.
  • 0
    Yeah that is the issue, I'm currently converting everything to immutable records so we can keep the dot notation in as many places as possible
  • 0
    @reduxtris That's a tedious task. Components, Actions, and Reducer cases. Plus the testing to go along with everything. I don't envy your refactoring.
Add Comment