Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatibility with redux-immutable-state-invariant #1

Open
jasonwong26 opened this issue Mar 25, 2018 · 1 comment
Open

Compatibility with redux-immutable-state-invariant #1

jasonwong26 opened this issue Mar 25, 2018 · 1 comment

Comments

@jasonwong26
Copy link

Hello,

First off, great library! I'm using it for a demo project and it has greatly simplified my codebase. In my dev build, I'm also using the leoasis/redux-immutable-state-invariant library to check for state mutations. I've found that your library can throw mutation warnings when adding/removing listeners.

I was able to resolve this in my local copy by modifying the reducer to do a deep copy when cloning the state:

// extracted from reducer.js
var _lodash = require('lodash.foreach');
var _cloneDeep = require('lodash.cloneDeep');

var _lodash2 = _interopRequireDefault(_lodash);
var _cloneDeep2 = _interopRequireDefault(_cloneDeep);

exports.default = function () {
  // other code...

  // clone the state
  // var newState = Object.assign({}, state);
  var newState = _cloneDeep2.default(state);

  // other code...
};

May I create a PR for this change?

@thesmilingsloth
Copy link

Yes, you can create a PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants