-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Calling .map() on an instance of Record modifies the original Record #645
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
Comments
Definitely looks like a bug (although the documentation is very unclear on what API Record instances actually have access to!). Should reify be like this:
?? That's just adding the 'new' keyword. It fixes your issue for me locally, but I don't know if it's the correct fix. An alternative might be
Not sure which fix is the better one! |
Agreed. The docs are a little unclear on many of the instance methods IMO. I often end up just running them in the console and seeing what happens. |
I believe this is by design.
|
Having trouble understanding why any method that mutated an Immutable instance would be intentional. |
That's a terrible behavior if it's intentional. A library called immutableJS should be 100% immutable, it's the sole reason it's useful. lodash has the same trap: it started as a decent functional lib then added all sort of crap like _.pull, _.pullAt and _.remove to directly mutate arrays. I don't see how this could be intentional. |
It's undefined behaviour (since |
See this issue: #505
|
Such methods should not be exposed or publicly accessible then. |
Wow, this is an incredibly unexpected behavior. Our project heavily relies on Immutable.js and makes extensive use of Records. This behavior lead to several hours of debugging effort since I didn't think it was possible to mutate the properties of a Record instance once constructed. I offer this feedback not to complain, but to illustrate how seriously this behavior deviates from what I expect as a user of the library. Hopefully this behavior is not intentional. #505 makes it sound like |
Merging into #505 |
Perhaps I'm missing something, but it seems like there is a problem with the
map()
function on records:The text was updated successfully, but these errors were encountered: