React, Redux, and Immutable

Viewed 460

What are the advantages of using Immutable with React (and optionally, Redux)? In Redux, I can simply use rest this in my reducers to return a new state:

const initialState = {
  activeTrackId: '',
  state: 'stopped',
};

export default function (state = initialState, action) {
  switch (action.type) {
    case actions.PROCESS_TRACK_ACTION:
      return {
        ...state,
        activeTrackId: action.state !== 'stopped' ? action.track._id : '',
        state: action.state,
      };
      // ...

The only scenario I've found it useful in was this:

shouldComponentUpdate(nextProps) {
  const oldProps = Immutable.fromJS(this.props);
  const newProps = Immutable.fromJS(nextProps);

  return !Immutable.is(oldProps, newProps);
}

And that might even be misusing it, as far as I know.

Maybe someone could enlighten me as to the advantage of using Immutable in the context of React and Redux?

2 Answers
Related