I've encountered an issue when trying to add a new property to an imported immutable record before using it as the default state for my application. Despite attempting methods like merge
, mergeDeep
, mergeWith
, and mergeDeepWith
, I wasn't able to successfully add the property. It seems that in all cases, the calling Record is returned. My attempts at using merge
were influenced by seeing this reference: this link.
The code snippet below demonstrates the issue:
a = Immutable.Record({a:1, b:2})
b = a()
c = Immutable.Record({z:12})
d = c()
e = b.merge(d)
console.log(e.toJS())
e = b.mergeDeep(d)
console.log(e.toJS())
e = b.mergeWith(d)
console.log(e.toJS())
e = b.mergeDeepWith(d)
console.log(e.toJS())
<script src="https://cdnjs.cloudflare.com/ajax/libs/immutable/3.8.2/immutable.js"></script>
This issue persists with both versions v3.8.2
and v4.0.0-rc-9
. In each case, only b
is being returned. I'm seeking a solution specifically using version 3.8.2
, not necessarily reliant on merge
.
I lack significant experience with immutability, so any guidance would be greatly appreciated.
Thank you in advance