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

using deep-assign package #15

Closed
ndamjan opened this issue May 26, 2017 · 5 comments
Closed

using deep-assign package #15

ndamjan opened this issue May 26, 2017 · 5 comments

Comments

@ndamjan
Copy link
Contributor

ndamjan commented May 26, 2017

I stumbled upon some strange exception where a nested field from a JSON object was missing... Can't reproduce it currently in JSFiddle.

To me it seems some like cloning issue so I checked where it happens, and the responsibility is on deep-assign package.

According to https://github.com/sindresorhus/deep-assign:

[DON'T USE THIS MODULE PLEASE]

Replacing it with object-assign doesn't work. I will see some alternatives and investigate further...

@marshallswain
Copy link
Member

LOL. That kinda of message ought to be in the readme. Thanks for finding that.

@ndamjan
Copy link
Contributor Author

ndamjan commented May 27, 2017

I found one more issue related to deep-assign - it doesn't make a deep clone of an object. This manifested itself as having the same refererence for an object property within both copy and current. So when I made changes to copy, they were being made to current also although the copy was not commited.

My workaround for this is to change a function in service-module/mutations.js to use clone function from ramda instead of deepAssign.

    setCurrent (state, item) {
      let id = isObject(item) ? item[idField] : item
      state.currentId = id
      // state.copy = deepAssign({}, item)
      state.copy = R.clone(item)
    },

@ndamjan
Copy link
Contributor Author

ndamjan commented May 29, 2017

Found also commitCopy and rejectCopy to be problematic because of deepAssign. I replace it the same way. Should we go for PR with this?

@marshallswain
Copy link
Member

@ndamjan Thanks for discovering all of this. Since the cloning is the only part of Ramda that we would be using, I'd prefer to go with a standalone solution like https://www.npmjs.com/package/lodash.clonedeep to keep the package size smaller.

@daffl
Copy link
Member

daffl commented Aug 18, 2017

Closed via #35 and released as v0.8.0

@daffl daffl closed this as completed Aug 18, 2017
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

3 participants