-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
updateIn
doesn't properly handle notSetValue
#1657
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
Your example is a bit confusing, could you clarify? From what I can see, the value at This code provides the output you are expecting: const { updateIn } = require('immutable')
const original = { x: { } }
const NOT_SET = { NOT_SET: true }
console.log(updateIn(original, ['x', 'y'], NOT_SET, val => NOT_SET)) // { x: {} } } I'm fairly certain that this is the intended behavior. |
From what I understood reading the docs. The third argument ( |
No, the third argument, is what is passed into the |
Interesting, so if I don't want to use const { updateIn } = require('immutable')
const original = { x: { y: undefined } }
const NOT_SET = { NOT_SET: true }
// { x: { y: undefined } }
console.log(updateIn(original, ['x', 'y'], NOT_SET, val => {
if (val === NOT_SET) return 'foo'
return val
})) And if I wanted to actually remove |
Yes, exactly. I agree that it's not the most intuitive behavior just by looking at the parameter name. |
The one confusing thing is how immutable-js/src/functional/updateIn.js Line 31 in 91c7c1e
|
@migueloller That is interesting. I had to dig into it more, and it appears that that behavior is there solely for the sake of |
Gotcha. And I guess because The reason I expected |
What happened
updateIn
doesn't properly handlenotSetValue
.How to reproduce
Expected the log output to be
{ x: {} }
instead. Is this intended behavior?The text was updated successfully, but these errors were encountered: