Skip to content

Question: Should I use immutable data structures #1422

@remojansen

Description

@remojansen

Hi,

I'm considering doing something to prevent bad state mutations. The first thing that I though about was immutable but then I started to think about the potential performance implications.

Some immutable checks will decrease performance because they are adding some run-time overhead. At the same time using immutable could improve performance when used in places like shouldComponentUpdate:

shouldComponentUpdate: function(nextProps, nextState) {
  return this.props.value !== nextProps.value;
}

So my main question are:

  1. Should I use immutable data structures?
  2. Should I use immutable data structures in production?
  3. Is the redux-immutable-state-invariant middleware a good alternative?

I was also trying to find out how to integrate immutable.js with Redux and I found two libraries:

Both libraries force you to use their custom implementation of combineReducers but there seems to be some problems with the reducers and middle-ware.

I have seem examples that use Redux + immutable.js without redux-immutable or redux-immutablejs so I'm not fully sure about those being really needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions